'Unable to push docker image to private repository - connect: no route to host

I am trying to push a docker image to a private docker repository from my local windows 10 machine running Docker Desktop with no success.

The command docker push 172.19.161.107:5000/ubuntu outputs the following:

Using default tag: latest
The push refers to repository [172.19.161.107:5000/ubuntu]
Get "http://172.19.161.107:5000/v2/": dial tcp 172.19.161.107:5000: connect: no route to host

When I go to the url http://172.19.161.107:5000/v2/, everything looks fine. From reading other posts, a lot of people are asking what curl says, so here is the output:

curl -i http://172.19.161.107:5000/v2
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=utf-8
Docker-Distribution-Api-Version: registry/2.0
Location: /v2/
Date: Wed, 02 Feb 2022 02:01:26 GMT
Content-Length: 39

The machine is a VM in Hyper-V. When I push the ubuntu image from another VM on the same switch, it gets uploaded to the repository and I am able to see it in the catalog api as show below:

curl -i http://172.19.161.107:5000/v2/_catalog
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Docker-Distribution-Api-Version: registry/2.0
X-Content-Type-Options: nosniff
Date: Wed, 02 Feb 2022 02:10:58 GMT
Content-Length: 37

{"repositories":["alpine","ubuntu"]}

From what I have read, it is very possibly a firewall issue, but I am not sure where to look. In my mind, if I am able to hit the URL and it loads, the port should be open. I have also allowed all traffic by default on my VMs.

What could be stopping me from pushing images from my local machine to my private repository?

Where should I look



Solution 1:[1]

I had similar issues which were solved by editing the daemon.json file for my local docker instance as follows

daemon.json

{
  "bip": "192.168.1.1/24",
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "features": {
    "buildkit": true
  },
  "insecure-registries": [
    "worker1.intra.net:30082"
  ]
}

The daemon.json can be accessed on the windows docker dashboard under
settings / Docker Engine
The entries which were added are "bip" and "insecure-registries".

  • "insecure-registries" allows http access instead of https,
  • "bip" sets the Bridge IP address range which was clashing locally with my kubernetes cluster.

In my setup I have a nexus-repository-manager running on a rke2 cluster,
however I'm using local storage so I have a node affinity to single worker node which is not ideal and could be made more resilient.

See also https://github.com/docker/for-win/issues/522

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1