Pull Docker from my private docker-registry without specifying the host

Muky picture Muky · Aug 6, 2014 · Viewed 12.3k times · Source

I am using docker-registry to pull my own docker images, but I want to do so without the need to specify the host. meanning: instead of writing:

docker pull <host>:<port>/<dockerImage>

I want to write:

docker pull <dockerImage>

and first it will try to pull the docker from my private registry, before trying to pull it from the public docker registry.

Is it possible?

I tried to change the DOCKER_INDEX_URL to [my_docker_registry_host]:[port], but it doesn't work.

Answer

pigletfly picture pigletfly · Dec 21, 2016

You can modify or add your /etc/sysconfig/docker

ADD_REGISTRY='--add-registry 192.168.0.169:5000'
INSECURE_REGISTRY='--insecure-registry 192.168.0.169:5000'

then modify /etc/systemd/system/docker.service or /usr/lib/systemd/system/docker.service

ExecStart=/usr/bin/dockerd --registry-mirror=http://192.168.0.169:5000

when you pull a image,docker will pull it from your private registry first,and then docker hub if not found in your private registry.I am working on CentOS 7 Docker 1.12.