2015-07-20 78 views
1

我想在docker中創建註冊表鏡像。我讀了tutorial。所以,我想在docker守護進程啓動時添加這個變量「--registry-mirror = http://10.0.0.2:5000」。如何在CentOS中添加變量到docker守護進程?

我在mac中成功了。我將該行添加到/ var/lib/boot2docker/profile:

EXTRA_ARGS="--registry-mirror=http://192.168.59.103:5555" 

它可以在mac中添加後工作。所以我在CentOS中做同樣的事情。我在這個question: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 /泊塢窗」 像CentOS的下方,這是我的搬運工文件:

# /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 

它沒有將變量添加到docker守護進程。哪裏不對?

+0

的[什麼區別的B/W 「的服務搬運工開始」 和 「搬運工-d」?](可能重複http://stackoverflow.com/questions/31472068/what- is-the-difference-bw-service-docker-start-and-docker -d) – booyaa

+0

@booyaa不,我在centos上使用這個命令,它沒有工作。 – v11

+0

那麼爲什麼不用正確的信息更新原始帖子,而不是打開類似的帖子? – booyaa

回答

2

/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,我不知道這個選項。

+0

謝謝,沒關係向docker守護進程添加變量。但鏡子仍然無法正常運行。我會接受你的回答,並提出新的問題,問爲什麼鏡像無法正常運行。 – v11

+0

僅供參考,碼頭包裝與發行版不同,在openSUSE上,我使用docker 1.6.2,'other_args'不存在,此外,sysconfig文件中使用的參數是'DOCKER_OPTS'而不是centos 'OPTIONS'。這可能會讓人困惑。 – superbob

+0

謝謝!你有任何想法這個問題:http://stackoverflow.com/questions/31517388/how-to-create-docker-registry-mirror-on-centos? – v11

0

如果您使用的是yum install docker,則可能會在docker服務配置文件中遇到問題。

然後你需要檢查你的系統服務配置文件,看它是否使用other_args作爲啓動docker的參數。默認情況下,服務配置文件應該放在/usr/lib/systemd/system/docker.service,用任何編輯器編輯它,檢查ExecStart部分,將other_args添加到它。

例如,ExecStart=/usr/bin/docker -d --selinux-enabled $other_args

+0

謝謝!你有任何想法這個問題:http://stackoverflow.com/questions/31517388/how-to-create-docker-registry-mirror-on-centos? – v11

相關問題