187

I use Docker toolbox for windows and I`m trying run private docker registry refering this documentation https://docs.docker.com/registry/deploying/

But it`s not working for me.

Error after this:

$ docker pull 192.168.99.100:5000/my-ubuntu

Error

$ docker pull 192.168.99.100:5000/image
Using default tag: latest
Error response from daemon: Get https://192.168.99.100:5000/v2/: http: server gave HTTP response to HTTPS client

I`m thinking that error is something in my docker client.

For information this is my docker info

Containers: 6
 Running: 4
 Paused: 0
 Stopped: 2
Images: 19
Server Version: 17.06.0-ce
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 144
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.4.74-boot2docker
Operating System: Boot2Docker 17.06.0-ce (TCL 7.2); HEAD : 0672754 - Thu Jun 29 00:06:31 UTC 2017
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 995.8MiB
Name: default
ID: ZMCX:NXC7:3BSV:ZNWV:MDZO:FW26:6MX5:UWI6:NVRL:XP56:AKGC:Z3TW
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 47
 Goroutines: 56
 System Time: 2018-04-05T13:43:42.856720067Z
 EventsListeners: 0
Username: kacalek
Registry: https://index.docker.io/v1/
Labels:
 provider=virtualbox
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

If I try this on mac everything is working perfectly.

Do you know how this error to solve?

Thank you so much for every answers!

1
  • My problem was that I had a typo in de daemon.json (like dEAmon.json) Commented Oct 6, 2023 at 12:57

19 Answers 19

232
+250

Looks like you haven't set the Docker Daemon right. Notice these few lines:

Insecure Registries:
 127.0.0.0/8

Try to add this line to Docker's daemon.json file and restart the Docker Daemon:
(C:\ProgramData\Docker\config\daemon.json on windows, /etc/docker/daemon.json on linux)

"insecure-registries":["192.168.99.100:5000"]
13
  • 1
    THX for answer. Where is daemon.json ? Commented Apr 5, 2018 at 15:39
  • 2
    It's in C:\ProgramData\Docker\config
    – Yuankun
    Commented Apr 5, 2018 at 15:50
  • 7
    But i found some config.json in "C:\Users\kacal\.docker" Commented Apr 6, 2018 at 11:55
  • 8
    FYI: On linux, this is in /etc/docker/daemon.json, according to docs.docker.com/registry/deploying Commented Oct 2, 2019 at 14:19
  • 8
    need to restart docker as well after changing the daemon.json? i needed to restart to flush these changes. sudo systemctl restart docker
    – John smith
    Commented Dec 6, 2022 at 17:01
109

On CentOS 7.2.1511, I had to create a new file

/etc/docker/daemon.json 

with the contents

{ "insecure-registries":["host:port"] } 

(The host is the hostname of the server hosting my docker registry and port is the port where the docker registry is available. In my case, those are 192.168.99.1:50000)

and then restart docker daemon by doing:

$ sudo service docker restart
3
  • 7
    After update daemon.json DON'T forget to restart docker service!!!
    – nix
    Commented May 11, 2020 at 8:02
  • 2
    But how to make it secure or use https ?
    – McLan
    Commented Jun 16, 2021 at 14:37
  • 5
    "systemctl docker reload" would be enough (and faster) Restart will kill all your stuff running :) Commented Dec 3, 2021 at 14:48
77

If you use windows:

  1. in startup menu, right-click on docker desktop, and select settings
  2. select "docker engine" tab, and change as in picture "insecure-registries": [], by "insecure-registries": ["192.168.99.1:5000"],

Docker engine tab

  1. Click apply and restart button
  2. After docker restart, to check that modification was applied, open cmd console and execute this command: docker system info then check that 192.168.99.1:5000 exists in "insecure-registries" section
4
  • 1
    How did you get the 192.168.99.1:5000 value?
    – PAA
    Commented May 21, 2021 at 16:22
  • 1
    To answer your quest PAA - that was the IP address of his registry, and the port - which defaults to 5000. Commented Mar 10, 2022 at 1:58
  • Also works for ubuntu (when using docker desktop). Creating the daemon json in top answers didn't work for me, but this works! :)
    – Hedgelot
    Commented Nov 5, 2022 at 12:02
  • works for ubuntu20 using docker-desktop Commented Jul 21, 2023 at 2:57
66

Hopefully this will help anyone having issues getting the insecure-registries fix to work.

Adding

{ "insecure-registries":["host:port"] }

to

/etc/docker/daemon.json

did not work for me until I created the file

/etc/default/docker

and put the line

DOCKER_OPTS="--config-file=/etc/docker/daemon.json"

in it and then restarted the docker daemon with

sudo systemctl stop docker and sudo systemctl start docker.

For some reason just doing a sudo systemctl restart docker did not work. It threw an error about trying to restart the service to quickly.

Also for ["host:port"] I used the IP of my Docker registry as opposed to the hostname as I did not have DNS or a hosts file setup to be able to find the registry by hostname.

This drove me absolutely nuts until I stumbled upon the /etc/default/docker bit here.

I am new to Docker and so I don't know if this is new requirement since this initial post was answered or if there was something else I missed when I first setup my registry. Though all I did was to follow the current docs on the Docker site itself.

27
+50

If buildkit is enabled (in newer versions it seems to be enabled by default) and adding the insecure-registries didn't fix it, you may need to either disable buildkit, or add the http:// to the hostnames in insecure-registries.

Disable Buildkit via environment variable:
DOCKER_BUILDKIT=0 docker build -t image_name .
Disable via docker daemon configuration file:
  • On Docker Desktop go to Settings > Docker Engine
    ** Be very careful of typos and missing commas as breaking this file will prevent docker desktop starting up.
{
  ...
  "features": {
    "buildkit": false << SET THIS TO FALSE
  },
  "insecure-registries": [
    "hostname:18443",
    "hostname:8083"
  ],
  ...
}
Configure URL as HTTP:
{
  ...
  "features": {
    "buildkit": true
  },
  "insecure-registries": [
    "http://hostname:18443",
    "http://hostname:8083"
  ],
  ...
}
Documentation of the known issue:

https://github.com/docker/docker.github.io/blob/62adddbb6b1f8d861c72f6ade2c50977fd57f481/registry/insecure.md#known-issue-on-buildkit

2
  • 8
    add the http:// to the hostnames in insecure-registries helped me, thanks! Commented Feb 10, 2023 at 5:28
  • 3
    Life Saver Solution! Commented Mar 23, 2023 at 19:35
13

If you are using Docker Desktop for Windows:

  • Click the docker whale icon in the task bar

  • A menu appears, click Settings

  • A popup appears, click Daemon

  • Entry your insecure registry in the "Insecure registries" text area

  • Click apply

Job done, no need to manually edit any files

2
  • 2
    This worked on my MacOS Docker Desktop as well. Be aware the daemon needed to be restarted, so any running containers will be killed. Commented Jan 19, 2021 at 22:56
  • Looks like they removed that feature from Windows Docker Desktop, as when I click on setting 1. I don't get a popup, 2. if I Assume you are just talking about the options that shows up: General/Resources/Docker Engine/Experimental Features/Kubernetes/Software Updates. (Update, Looks like the answer below has an image of what you see, and you need to go into Docker Engine) Commented Mar 9, 2022 at 23:04
9

Maybe someone bumps into this as well again, @user674669 should also have mentioned that the sudo /etc/docker/daemon.json should be set on the client machine that wants to connect to the Docker registry in question.

This allows the client to connect to the server

2
  • 1
    That's the key, it`s neccesary in the client machine and I was doing at server machine thanks! Commented May 12, 2021 at 12:55
  • That's the key. Thanks! Commented Aug 8, 2023 at 15:01
6

If you are using minikube in Windows machine along with minikube addons registry.

1.Find the registry IP. It will be same as minikube IP.

> minikube ip

2.Edit the file:

C:\Users\<username>\.minikube\machines\minikube\config.json

 "InsecureRegistry": [
                "10.96.0.0/12",      // Add coma
                "<minikube IP>:5000" //-> Add this line
            ],
  1. Restart minikube

    > minikube start

3

necron9x11's answer worked for me. Note that if you're working with a Docker-in-Docker deployment such as containerized Jenkins (https://www.jenkins.io/doc/book/installing/docker/), you can add the "daemon.json" and "docker" files as part of your image build. This way both are included with your deployable dind image supporting the Jenkins image. Just create both files in the same directory with your Dockerfile:

enter image description here

Then the contents of the Dockerfile are:

FROM docker:dind
USER root
ADD docker /etc/default/docker
ADD daemon.json /etc/docker/daemon.json

Lastly build and deploy as usual:

docker build -f Dockerfile.dind -t dind-custom .
docker run ...
   (name + env + volume + etc)
   dind-custom

Now your dind container can access the insecure registries specified as ["host:port"] in daemon.json.

2

Here is an official page explain for "Test an insecure registry". Solutions:

  1. Add "insecure-registries" (The major solution in this thread.)
  2. Use self-signed certificates

https://docs.docker.com/registry/insecure/

2
http: server gave HTTP response to HTTPS client

To resolve this issue I had to edit registries.conf under /etc/containers and add entry of docker server "Host:Port"

[registries.insecure]
registries = ['host:port']

Then create a file named docker under /etc/default adding below line

DOCKER_OPTS="--config-file=/etc/containers/registries.conf"

save the file and reload docker using systemctl reload docker and try docker login.

As this question is already answered but in some cases it does not work an in some cases daemon.json under path /etc/docker/ works perfectly

1
2

If using docker-snap, the daemon config file is located at /var/snap/docker/current/etc/docker https://github.com/docker-archive/docker-snap/issues/22 . The issue also mentioned /var/snap/docker/current/config/

I was able to resolve this issue (with docker-snap), via adding

"insecure-registries": ["my.url:port"] To /var/snap/docker/current/config/daemon.json and /var/snap/docker/current/etc/docker/daemon.json. To affect the changes, sudo snap restart docker

1

I installed new version of Docker in Ubuntu and none of the approaches works, so I install older docker

sudo apt-get install docker-ce=5:19.03.12~3-0~ubuntu-focal

and works as normal

1
  • Any idea which version of docker "broke" your configuration?
    – Otheus
    Commented Sep 10, 2023 at 10:22
1

I was trying to push my local docker images to my private docker registry in remote server. This worked for me [Windows]:

  1. Open your text editor (mine is Sublime text) as administrator.

  2. Make sure in windows explorer you can see hidden folders. You can
    check it out by going to View -> Hidden items checkbox.

  3. Open daemon.json file located at C:\Users\your_user\.docker

  4. This is how it looks like:

    { "builder": { "gc": { "defaultKeepStorage": "20GB", "enabled": true } }, "experimental": false, "features": { "buildkit": true } }

  5. Add insecure-registries field to the json:

    { "builder": { "gc": { "defaultKeepStorage": "20GB", "enabled": true } }, "experimental": false, "features": { "buildkit": true }, "insecure-registries": ["host_you_want_to_push:5000"] }

  6. Save the file. Restart Docker by going to Docker desktop icon in right bottom corner of taskbar.

  7. Try it now

1

I also add insecure-registries host into the /etc/docker/daemon.json file then restart, start, stop docker service but it didn't work, after many try I restart machine then it work.

So, try to restart your computer or VM if it didn't work

0

I also faced the same issue. After hours of effort I figured out I need to define insecure registry as follows.

If the hosts file mapping is 192.168.0.xx docker.local then daemon.json should have the insecure registry (in etc/docker/daemon.json) key should be: ... "insecure-registries":["docker.local:5000"] ... Earlier it was like: ... "insecure-registries":["192.168.0.xx:5000"] ...

0

If you are using Unraid, changes in /etc/docker are not persistent during shutdown/restart cycle.

I had to add 3 lines to /boot/config/go in order to create the daemon file during boot

# Create docker daemon.json
mkdir /etc/docker
echo {\"insecure-registries\": [\"<your-ip>:5000\"]} > /etc/docker/daemon.json

There might be a better solution but that was working for me.

0

I just spent hours trying to debug WSL. It turns out it's a combination of having the insecure-registries right, but also not having DOCKER_TLS_VERIFY set on the other side. Having that set to 0 or 1 broke it, so I had to unset the variable and it worked.

-1

I have to rm -Rf ~/.docker besides change the daemon.json.

credit: https://github.com/moby/moby/issues/28321#issuecomment-638307611

Not the answer you're looking for? Browse other questions tagged or ask your own question.