By default, if I issue command:
sudo docker pull ruby:2.2.1
it will pull from the docker.io offical site by default.
Pulling repository docker.io/library/ruby
How do I change it to my private registry. That means if I issue
sudo docker pull ruby:2.2.1
it will pull from my own private registry, the output is something like:
Pulling repository my_private.registry:port/library/ruby
UPDATE: Following your comment, it is not currently possible to change the default registry, see this issue for more info.
You should be able to do this, substituting the host and port to your own:
If the server is remote/has auth you may need to log into the server with:
Then running:
It seems it won't be supported due to the fragmentation it would create within the community (i.e. two users would get different images pulling
ubuntu:latest
). You simply have to add the host in front of the image name. See this github issue to join the discussion.(Note, this is not intended as an opinionated comment, just a very short summary of the discussion that can be followed in the mentioned github issue.)
if you are using the fedora distro, you can change the file
Adding domain docker.io
It turns out this is actually possible, but not using the genuine Docker CE or EE version.
You can either use Red Hat's fork of docker with the '--add-registry' flag or you can build docker from source yourself with registry/config.go modified to use your own hard-coded default registry namespace/index.
Earlier this could be achieved using
DOCKER_OPTS
in the/etc/default/docker
config file which worked on Ubuntu 14:04 and had some issues on Ubuntu 15:04. Not sure if this has been fixed.The below line needs to go into the file
/etc/default/docker
on the host which runs the docker daemon. The change points to the private registry is installed in your local network. Note: you would require to restart the docker service followed with this change.Haven't tried, but maybe hijacking the DNS resolution process by adding a line in
/etc/hosts
forhub.docker.com
or something similar (docker.io
?) could work?