dockerubuntu

Connection refused on pushing a docker image


I'm going to setup a local registry by following https://docs.docker.com/registry/deploying/.

 docker run -d -p 5000:5000 --restart=always --name reg ubuntu:16.04

When I try to run the following command:

$ docker push localhost:5000/my-ubuntu

I get Error:

Get http://localhost:5000/v2/: dial tcp 127.0.0.1:5000: connect:connection refused

Any idea?


Solution

  • Connection refused usually means that the service you are trying to connect to isn't actually up and running like it should. There could be other reasons as outlined in this question, but essentially, for your case, it simply means that the registry is not up yet.

    Wait for the registry container to be created properly before you do anything else - docker run -d -p 5000:5000 --restart=always --name registry registry:2 that creates a local registry from the official docker image.

    Make sure that the registry container is up by running docker ps | grep registry, and then proceed further.