How to create docker registry mirror

会有一股神秘感。 提交于 2019-12-08 04:26:28

问题


I use MAC OS X.And I want to use mirror in this tutorial, its step 1 is need to do this:

docker --registry-mirror=http://<my-docker-mirror-host> -d

But, when I use this command in terminal, it did't work:

flag provided but not defined: --registry-mirror See 'docker --help'.

then, I use the other way in tutorial:

you may be able to add the --registry-mirror options to the DOCKER_OPTS variable in /etc/default/docker

I don't know where to add this DOCKER_OPTS. I want to use mirror in client 1.7.0. Can anyone tell me how to set up the mirror?.
I use this command to create mirror:

docker run -d -p 5000:5000 -e REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/Users/v11/Documents/docker-registry --restart=always --name mirror -e STANDALONE=false -e MIRROR_SOURCE=https://registry-1.docker.io -e MIRROR_SOURCE_INDEX=https://index.docker.io registry

I test it and find it didn't work like it describe that can download from local registry. Even if I fail to use this command :

docker push localhost:5000/batman/ubuntu

This command can work before, I really don't know what happened. Maybe the flag "STANDALONE=false" affect? I want to setup mirror, can anyone tell me how to do.Thanks.


回答1:


The problem is the command:

$ docker --registry-mirror=http://<my-docker-mirror-host> -d

Is intended for configuring the Docker daemon, not the Docker client. In boot2docker (which is what you're presumably using), this means you need to log into the boot2docker VM and run those commands there.

You can log into the boot2docker VM with boot2docker ssh. Whilst you could just stop the daemon and restart with the new commands, it's best to edit the file /var/lib/boot2docker/profile which will be used each time boot2docker restarts. Just add something like:

EXTRA_ARGS="--registry-mirror=http://<my-docker-mirror-host>"

If you then restart boot2docker, you should be good to go.



来源:https://stackoverflow.com/questions/31453813/how-to-create-docker-registry-mirror

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