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
?
相关问题
- Docker task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
This solution works on Red Hat 7.2 & Docker 1.12.0
Edit the file /lib/systemd/system/docker.service in your text editor.
add -g /path/to/docker/ at the end of ExecStart directive. The complete line should look like this.
Execute the below command
Execute the command to check docker directory
If you have /etc/sysconfig/docker file in Red Hat or docker 1.7.1 check this answer.
Copy-and-paste version of the winner answer :)
Create this file with only this content:
$ sudo vi /etc/docker/daemon.json
Tested on
Ubuntu 16.04.2 LTS
in docker1.12.6
For Debian/Ubuntu or Fedora, you can probably use the other answers. But if you don't have files under
/etc/default/docker
or/etc/sysconfig/docker
, and your system is running systemd, you may want to follow this answer by h3nrik. I am using Arch, and this works for me.Basically, you need to configure systemd to read the new docker image location as an environment variable, and pass that environment variable into the Docker daemon execution script.
For completeness, here is h3nrick's answer:
Do you have a
/lib/systemd/system/docker.service
file?If so, edit it so that the Docker service uses the usual
/etc/default/docker
as an environment file:EnvironmentFile=-/etc/default/docker
.In the
/etc/default/docker
file then addDOCKER_OPTS="-g /home/rseixas/Programs/Docker/images"
.At the end just do a
systemctl daemon-reload && systemctl restart docker
.For further information please also have a look at the documentation.
A much simpler solution is to create a soft link point to whatever you want, such as
It works for me on my CentOS 6.5 server.