13

I have created my own private registry on my server by pulling and running the registry image.

sudo docker run -d -p 5000:5000 registry

After which, I tried to tag a simple image and push it to the server.

sudo docker tag ubuntu:latest localhost:5000/myprivateubuntu

And I received this error:

Error: Invalid registry endpoint ... Get ... If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add '--insecure-registry localhost:5000' to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/localhost:5000/ca.crt

Anyhow know what's the problem?

Hans
  • 451
  • 1
  • 6
  • 20
  • 6
    Have you read the error message, and added `--insecure-registry localhost:5000` to the daemon's arguments, and restarted the daemon? – Thomas Orozco Nov 14 '14 at 10:46

4 Answers4

23

stop the service.

sudo service docker stop

restart service with --insecure-registry arguments:

/usr/bin/docker -d --insecure-registry localhost:5000

or edit /etc/default/docker file and add the following line:

DOCKER_OPTS="--insecure-registry localhost:5000"
cizixs
  • 12,931
  • 6
  • 48
  • 60
  • Yes, same solution suggested here: http://wanderingquandaries.blogspot.co.uk/2014/11/setting-up-insecure-docker-registry.html – Miguel Marques Nov 27 '14 at 16:11
  • 3
    I'm using Docker 1.7 and --insecure-registry appears to only work if I start the daemon directly. Editing `/etc/default/docker` or setting `DOCKER_OPTS` directly in the init script seems to have no effect. – David Carboni Jun 24 '15 at 14:45
  • 1
    I have the same error so I'm trying to fix it with the insecure flag but the command isn't recognized? `sudo service docker start -d --insecure-registry openshift Redirecting to /bin/systemctl start -d --insecure-registry openshift docker.service /bin/systemctl: invalid option -- 'd'` (also without --d it's not possible) – lvthillo Oct 01 '15 at 07:06
2

From comments of the accepted answer, it looks like the solution does not works for all. The following solution works for me.

Create systemd conf override file for Docker

sudo mkdir /etc/systemd/system/docker.service.d
sudo touch /etc/systemd/system/docker.service.d/docker.conf
sudo vi /etc/systemd/system/docker.service.d/docker.conf

Add these following line and save it

[Service]
ExecStart=
ExecStart=/usr/bin/docker daemon -H fd:// $DOCKER_OPTS
EnvironmentFile=-/etc/default/docker

Edit /etc/default/docker

sudo vi /etc/default/docker

Add the following line and save it. Replace localhost:5000 with your registry domain name and port

DOCKER_OPTS="--insecure-registry localhost:5000"

Restart docker daemon

Reload overriden configuration and restart docker as follows

sudo systemctl daemon-reload
sudo systemctl restart docker 
030
  • 10,842
  • 12
  • 78
  • 123
Nur Rony
  • 7,823
  • 7
  • 38
  • 45
0

Setting Local insecure registry in docker along with proxy:

1) in ubuntu add the following flag --insecure-registry IP:port under DOCKER_OPTS in file /etc/default/docker

1.1) configure no_proxy env variable to bypass local IP/hostname/domainname...as proxy can throw a interactive msg ...like continue and this intermediate msg confuses docker client and finally timesout...

1.2) if domainname is configured...then don't forget to update /etc/hosts file if not using DNS.

1.3) in /etc/default/docker set the env variables http_proxy and https_proxy...as it enables to download images from outside company hubs. format http_proxy=http://username:password@proxy:port

2) restart the docker service...if installed as service, use sudo service docker restart

3) restart the registry container [sudo docker run -p 5000:5000 registry:2 ]

4) tag the required image using sudo docker tag imageid IP:port/imagename/tagname ifany

5) push the image ...sudo docker push ip:port/imagename

6) If u want to pull the image from another machine say B without TLS/SSL,then in B apply setps 1,1.1 and 2. If these changes are not done in machine B...pull will fail.

Ragha
  • 11
  • 2
0

My solution, built on top of the prior ones.

# docker -v
Docker version 18.09.1, build 4c52b90
# uname -a
Linux host 4.15.0-43-generic #46~16.04.1-Ubuntu SMP Fri Dec 7 13:31:08 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Contents of my /etc/docker/daemon.json file:

{
    "runtimes": {
        "nvidia": {
            "path": "/usr/bin/nvidia-container-runtime",
            "runtimeArgs": []
        }
    },
    "insecure-registries" : [
        "ipaddress:port"
      ],
    "experimental" : false,
    "debug" : true
}

where ipaddress:port is the dotted IPv4 address of the registry machine followed by the registry port (e.g. 127.0.0.1:12345). I did not have to prefix with http:// or anything like that.

No changes to /etc/default/docker

And then I reloaded and restarted the daemon with:

# sudo systemctl daemon-reload
# sudo systemctl restart docker

docker push to the insecure registry works now.

schnee
  • 1,050
  • 2
  • 9
  • 20