MySQL on Docker

How to setup a private docker re

2018-05-16  本文已影响0人  凸大愚若智凸

Ok, eventually you'd build your private docker registry.
Here just to introduce a quick way of setup an insecure registry, not even using TLS. So don't use this in your production environment, but for fun, yes.

Suppose that IP address of your host for the registry is 10.0.2.5.

1. Run below command to setup a private registry that:

docker run -d --name registry -p 5000:5000 --restart=always -v /opt/registry/:/var/lib/registry/ registry

2. Pull an image from public

docker pull busybox

3. Tag the image with new name (<host>:<port>/<name>:<tag>)

docker tag busybox 10.0.2.5:5000/busybox

4. Push the image to private registry

docker push 10.0.2.5:5000/busybox

Oops, it doesn't work, with some error like below:

curl: (7) Failed to connect to 10.0.2.5 port 80: Connection refused

But if you use localhost or 127.0.0.1 instead of 10.0.2.5, it does work.
Let's get this fixed.

5. Change configuration in /etc/docker/daemon.json.

{
    "insecure-registries" : ["10.0.2.5:5000"]
}

6. Restart docker

sudo systemctl daemon-reload
sudo systemctl restart docker

OK, now it works.
And if you apply step 5 and 6 in another host, then you can access the registry from that host too. Give it a try.

上一篇下一篇

猜你喜欢

热点阅读