Relocating the Docker root directory

If the file space in the Docker root directory is not adequate, you must relocate the directory.

Procedure

To relocate the Docker root directory, complete the following steps as root user or as a user with sudo all authority:

  1. Stop the Docker services:
    sudo systemctl stop docker
    sudo systemctl stop docker.socket
    sudo systemctl stop containerd
  2. Create the necessary directory structure into which to move Docker root by running the following command.
    This directory structure must reside on a file system with at least 50 GB of free disk space. Significantly more disk space might be required, depending on the daily ingestion volumes and data retention policy.
    sudo mkdir -p /new_dir_structure
  3. Move Docker root to the new directory structure:
    sudo mv /var/lib/docker /new_dir_structure
  4. Edit the file /etc/docker/daemon.json. If the file does not exist, create the file by running the following command:
    sudo vim /etc/docker/daemon.json
    Add the following information to this file:
    {
      "data-root": "/new_dir_structure/docker"
    }
  5. After the /etc/docker/daemon.json file is saved and closed, restart the Docker services:
    sudo systemctl start docker
    After you run the command, all Docker services through dependency management restart.
  6. Validate the new Docker root location:
    docker info -f '{{ .DockerRootDir}}'