Search code examples
docker

How to change the docker image installation directory?


From what I can tell, docker images are installed to /var/lib/docker as they are pulled. Is there a way to change this location, such as to a mounted volume like /mnt?


Solution

  • With recent versions of Docker, you would set the value of the data-root parameter to your custom path, in /etc/docker/daemon.json (according to https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file).

    With older versions, you can change Docker's storage base directory (where container and images go) using the -goption when starting the Docker daemon. (check docker --help). You can have this setting applied automatically when Docker starts by adding it to /etc/default/docker