美文网首页MySQL on Docker
How to setup a private docker re

How to setup a private docker re

作者: 凸大愚若智凸 | 来源:发表于2018-05-16 16: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:

    • Uses 5000 of host port and 5000 of target part
    • Mount /opt/registry as repository storage
    • restart flag keeps the registry running
    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.

    相关文章

      网友评论

        本文标题:How to setup a private docker re

        本文链接:https://www.haomeiwen.com/subject/yiopdftx.html