如何在CentOS中添加variables到docker守护进程?
我想在docker中创buildregistry镜像。 我读了这个教程 。 所以,我想在docker守护进程启动的时候添加这个variables“–registry-mirror = http://10.0.0.2:5000 ”。
我在mac上成功了。 我将这行添加到/ var / lib / boot2docker / profile:
EXTRA_ARGS="--registry-mirror=http://192.168.59.103:5555"
它可以在mac中添加后工作。 所以我在CentOS中做同样的事情。 我在这个问题中使用这个命令:I :
sudo sed -i 's|other_args=|other_args=--registry-mirror=http://<my-docker-mirror-host> |g' /etc/sysconfig/docker sudo sed -i "s|OPTIONS='|OPTIONS='--registry-mirror=http://<my-docker-mirror-host> |g" /etc/sysconfig/docker sudo service docker restart
它使得我的“/ etc / sysconfig / docker”如下面的CentOS,这是我的docker文件:
# /etc/sysconfig/docker # # Other arguments to pass to the docker daemon process # These will be parsed by the sysv initscript and appended # to the arguments list passed to docker -d OPTIONS=--selinux-enabled -H fd:// -g="/opt/apps/docker" other_args="--registry-mirror=http://10.11.150.76:5555"
然后,我使用这个命令重新启动docker:
service docker restart
但是,镜像在CentOS中不起作用。 我使用命令:
ps -ef
它没有将variables添加到docker守护进程。 哪里不对?
在/etc/sysconfig/docker
文件中,更改:
OPTIONS=--selinux-enabled -H fd:// -g="/opt/apps/docker"
成:
OPTIONS=--selinux-enabled -H fd:// -g="/opt/apps/docker" --registry-mirror=http://10.11.150.76:5555
我帮other_args
,我不知道这个选项。
如果你使用yum install docker
,你可能会遇到Docker服务configuration文件的问题。
然后你需要检查你的系统服务configuration文件,看看是否使用other_args
作为参数来启动other_args
。 默认情况下,服务configuration文件应该放置在/usr/lib/systemd/system/docker.service
,用任何编辑器编辑,检查ExecStart
部分,添加other_args
。
例如, ExecStart=/usr/bin/docker -d --selinux-enabled $other_args