Docker is not able to resolve container name in bridge network

Hey guys,

I currently facing a problem with the dns lookup. Here is my setup:

Host machine is running CentOS and Docker version 18.06.1-ce build e68fc7a

I use docker-compose with default network settings:

version: '3'

    image: registry:latest
    container_name: DockerRegistry
      - ~/docker-registry:/var/lib/registry
      - 60000:5000
    restart: unless-stopped

    image: codeneko/jenkins-with-docker:lts
    container_name: Jenkins
      - ~/jenkins_home:/var/jenkins_home
      - /var/run/docker.sock:/var/run/docker.sock
      - 50001:8080
    restart: unless-stopped

I use Jenkins to build a docker image which works just fine. The problem comes, when I’m trying to push to the local docker registry. For development I don’t have any security considered, so it’s http without authentication. Therefor I added the following to the /etc/docker/deamon.json file on my host, to allow the use of an insecure registry:

 "insecure-registries" : ["docker-registry:5000"]

And then I’m creating the docker file (in the jenkins container) with the name docker-registry:5000/some/name:1.0.0. When I try to push it to the local docker registry (container docker-registry) by calling docker push docker-registry:5000/some/name:1.0.0. It fails with the following error:

docker push docker-registry:5000/some/name:1.0.0
The push refers to repository [docker-registry:5000/some/name]
Get http://docker-registry:5000/v2/: dial tcp: lookup docker-registry on server misbehaving

But if I try to reach the same url with curl curl http://docker-registry:5000/v2/ it works just fine and it can resolve the container name.

In my opinion it’s exactly the same http request, but one time docker can resolve the container name and the other time it can’t.

Any suggestions?