1

I want to create registry mirror in docker. I read this tutorial. So,I want to add this variable "--registry-mirror=http://10.0.0.2:5000" to docker daemon when it start.

I have succeeded in mac. I add the line to /var/lib/boot2docker/profile:

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

It can work after adding in mac. So I do the same thing in CentOS. I use the command in this 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

and it makes my "/etc/sysconfig/docker" like below in CentOS, and this is my docker file:

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

Then, I restart docker using this command:

service docker restart

But, the mirror didn't work in CentOS. I use command:

ps -ef

It did't add the variable to docker daemon. what is wrong?

Community
  • 1
  • 1
v11
  • 2,124
  • 7
  • 26
  • 54
  • possible duplicate of [What is the difference b/w "service docker start" and "docker -d"?](http://stackoverflow.com/questions/31472068/what-is-the-difference-b-w-service-docker-start-and-docker-d) – booyaa Jul 20 '15 at 09:07
  • @booyaa No, I use the command on centos, it didn't work. – v11 Jul 20 '15 at 09:11
  • so why not update the original post with the correct information rather than open a similar looking post? – booyaa Jul 20 '15 at 09:20
  • In original post, I just want to know the different b/w they. – v11 Jul 20 '15 at 09:22
  • Why not put everything into `OPTIONS`? `other_args` doesn't mean anything to docker. – superbob Jul 20 '15 at 09:22
  • @superbob How to add it? Is it ok to just add to OPTIONS? Can you edit my docker file and answer this question? – v11 Jul 20 '15 at 09:24
  • @v11, I don't see a Dockerfile in your question, only the contents of `/etc/sysconfig/docker` config file which is not a Dockerfile – superbob Jul 20 '15 at 09:28
  • I've summed up everything to an answer – superbob Jul 20 '15 at 09:30

2 Answers2

2

In the /etc/sysconfig/docker file, change:

OPTIONS=--selinux-enabled -H fd:// -g="/opt/apps/docker"

into:

OPTIONS=--selinux-enabled -H fd:// -g="/opt/apps/docker" --registry-mirror=http://10.11.150.76:5555

I can't help you with other_args, I don't know this option.

superbob
  • 1,628
  • 13
  • 24
  • Thanks, It is ok to add variable to docker daemon. But the mirror still can't run normally. I will accept your answer, and new a problem to ask why mirror can't run normally. – v11 Jul 20 '15 at 12:49
  • FYI, docker packaging differs from on distro to the other, on openSUSE with docker 1.6.2 which i'm using, `other_args` doesn't exist, moreover the parameter used in the sysconfig file is `DOCKER_OPTS` instead of the centos `OPTIONS`. That can be confusing. – superbob Jul 20 '15 at 14:36
  • Thanks! Do you have any idea for that question:http://stackoverflow.com/questions/31517388/how-to-create-docker-registry-mirror-on-centos? – v11 Jul 20 '15 at 14:39
0

If you using yum install docker, you may get a problem with the docker service config file.

Then you need to check your system service config file, see if it using other_args as a parameter to start docker. By default, the service config file should placed at /usr/lib/systemd/system/docker.service, edit it with any editor, check ExecStart part, add other_args to it.

For example, ExecStart=/usr/bin/docker -d --selinux-enabled $other_args

Freeznet
  • 537
  • 2
  • 6
  • Thanks! Do you have any idea for that question:http://stackoverflow.com/questions/31517388/how-to-create-docker-registry-mirror-on-centos? – v11 Jul 20 '15 at 14:39