Change Docker Root Dir on Red Hat Linux?

The Docker documentation on controlling the Docker daemon suggests that platform independent way to do this is:

edit the /etc/docker/daemon.json file to contain the line

{
    "data-root": "/mnt/docker-data",
    (...)
}

where /mnt/docker-data is the directory where you want the docker images and containers to live.

Then

sudo systemctl restart docker

You can check whether it worked by running

docker info

and look for the contents of the line that start with Docker Root Dir:.


Stop all running docker containers and then docker daemon. Move "/var/lib/docker" directory to the place where you want to have this data. For you it would be:

mv /var/lib/docker /data/

and then create symlink for this docker directory in /var/lib path:

ln -s /data/docker /var/lib/docker

Start docker daemon and containers.