How to get remote access to a private docker-registry?

前端 未结 15 553
攒了一身酷
攒了一身酷 2020-11-30 18:45

I\'m trying to setup a private docker registry using the image taken from: https://github.com/docker/docker-registry

Just by running:
docker run -p 5000:50

相关标签:
15条回答
  • 2020-11-30 19:09

    This is based on the answer from vikas027 on Centos 7 and Docker 1.12

    Since I am behind a proxy my full solution was ...

    /etc/systemd/system/docker.service.d/http-proxy.conf

    [Service]
    
    Environment="FTP_PROXY={{MY_PROXY}}"
    Environment="ftp_proxy={{MY_PROXY}}"
    
    Environment="HTTPS_PROXY={{MY_PROXY}}"
    Environment="https_proxy={{MY_PROXY}}"
    
    Environment="HTTP_PROXY={{MY_PROXY}}"
    Environment="http_proxy={{MY_PROXY}}"
    
    Environment="NO_PROXY=localhost,127.0.0.1,{{MY_INSECURE_REGISTRY_IP}}"
    Environment="no_proxy=localhost,127.0.0.1,{{MY_INSECURE_REGISTRY_IP}}"
    

    /usr/lib/systemd/system/docker.service

    ExecStart=/usr/bin/dockerd --insecure-registry {{MY_INSECURE_REGISTRY_IP}}:5000
    

    and dont forget to restart :)

    sudo systemctl daemon-reload; sudo systemctl restart docker;
    
    0 讨论(0)
  • 2020-11-30 19:10

    To save you hassle, why don't you just use the FREE private docker registry service provided by gitlab - works great

    https://about.gitlab.com/2016/05/23/gitlab-container-registry/

    Their registry is secure so you won't have any issues

    0 讨论(0)
  • 2020-11-30 19:11

    Ok. Here is how I got it to work. If you see this error in docker 1.3.2 or above, do this

    go to /etc/sysconfig/docker

    other_args="--insecure-registry 10.0.0.26:5000"
    

    and run

    sudo service docker restart

    0 讨论(0)
  • 2020-11-30 19:13

    I found the following to be very useful as it discusses how the Docker service itself is configured. https://docs.docker.com/articles/systemd/

    Along with this article on the systemctl command https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units

    I used the following series of commands in a Centos 7 based container with a registry image obtained by "docker pull registry:2.1.1"

    sudo mkdir -p /etc/systemd/system/docker.service.d
    cd /etc/systemd/system/docker.service.d
    sudo touch override.conf
    sudo nano override.conf
    

    And inside the override.conf added the following.

    [Service]
    ExecStart=
    ExecStart=/usr/bin/docker -d -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --insecure-registry 10.2.3.4:5000
    

    Note the first, blank, ExecStart= clears anything that is already in place so be sure to add anything from the /usr/lib/systemd/system/docker.service ExecStart= statement that you wish to retain.

    If you don't specify the -d(daemon) option you'll get a "Please specify only one -H" error.

    After issuing the following series of commands I can see my overrides in place.

    sudo systemctl stop docker
    sudo systemctl daemon-reload
    sudo systemctl start docker
    sudo systemctl status docker
    
    docker.service - Docker Application Container Engine
       Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
      Drop-In: /etc/systemd/system/docker.service.d
               └─override.conf
       Active: active (running) since Thu 2015-09-17 13:37:34 AEST; 7s ago
         Docs: https://docs.docker.com
     Main PID: 5697 (docker)
       CGroup: /system.slice/docker.service
               └─5697 /usr/bin/docker -d -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --insecure-registry 10.2.3.4:5000
    

    NOTE: The information provided by Loaded: and Drop-In: lines in the status message, the are useful for checking what's happening with a pre-existing docker daemon to work.

    NOTE: Also have a look in the Loaded: docker.service file for an EnvironmentFile= for further clues.

    0 讨论(0)
  • 2020-11-30 19:14

    use the following command replacing {YOUR_REGISTRY} with your registry

    boot2docker ssh "echo $'EXTRA_ARGS=\"--insecure-registry {YOUR_REGISTRY}\"' | sudo tee -a /var/lib/boot2docker/profile && sudo /etc/init.d/docker restart"
    
    0 讨论(0)
  • 2020-11-30 19:14

    Docker 1.12.1

    For CentOS 7.2

    /usr/lib/systemd/system/docker.service
    #ExecStart=/usr/bin/dockerd
    ExecStart=/usr/bin/dockerd --insecure-registry my-docker-registry.com:5000
    

    For ubuntu 16.04

    /lib/systemd/system/docker.service
    #ExecStart=/usr/bin/dockerd -H fd://
    ExecStart=/usr/bin/dockerd --insecure-registry my-docker-registry.com:5000 -H fd://
    
    sudo systemctl stop docker
    sudo systemctl daemon-reload
    sudo systemctl start docker
    

    It seems the --insecure-registry option may be used both with and without the "=" between it and the registry ID.

    0 讨论(0)
提交回复
热议问题