Cannot change Docker image directory

放肆的年华 提交于 2019-12-12 13:33:32

问题


I am using Fedora 22 and I must change my Docker image directory from

/var/lib/docker

to

/home/my_user/docker

Following this How to change the docker image installation directory? I edited the /etc/sysconfig/docker adding:

other_args="-g /home/rseixas/Programs/Docker/images"

I restarted the service but no change. In fact I restarted my machine and I am not able to see it changing.

Someone can help me?


回答1:


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 add DOCKER_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.




回答2:


In docker 1.8+ the service file settings changed a little:

[Service]
EnvironmentFile=-/etc/default/docker
# in docker 1.7 use ExecStart:
ExecStart=/usr/bin/docker -d $DOCKER_OPTS -H fd://
# in docker 1.8 use ExecStart:
ExecStart=/usr/bin/docker daemon $DOCKER_OPTS -H fd://
MountFlags=slave
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity

& some other notes for Debian / Fedora with the latest docker & a custom directory.



来源:https://stackoverflow.com/questions/31817065/cannot-change-docker-image-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!