Docker in Docker is unable to connect to local hostnames

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

Docker in Docker, dind, is unable to connect to local ip/hostnames a connection failure is seen. Logging into the runner container and try to debug the connectivity to local ip/hostnames is successful.

Solution

Environment

This applies only to self hosted docker based pipeline runners.

Scenario-1

  • Cause

    • This behaviour can occur if the java version is out of date.

  • Solution

    • Please update the java version and try again.

    • If you continue to encounter connection issues to local ip/hostnames please contact support

Scenario-2

  • Cause

    • This behavior could also occur if your host's IP address is in the same range of your docker bridge network addresses, which is causing a conflict in the routing and thus your are not being able to access the IP of the host.

    • When you run a new container docker will by default attach this container to an isolated bridge network. This is a private network where containers can access each other, and the default IP range for this bridge network is 172.17.*.* (172.17.0.1/16).

    • Your host's IP address (where you are executing the runner) is also in the same IP range 172.17.*.* as the docker bridge, so when you try to connect to the host's IP, the docker bridge thinks this is a container internal IP and is not going through the default gateway, causing a "No route to host" error.

  • Solution

    • In order to fix this, We would suggest changing the Default Bridge IP range(docker subnet) of your docker environment to a range that is not conflicting with the host's, for example 172.26.*.*

    • This can be done by editing the file daemon.json and adding the field "bip": "172.26.0.1/16". This file is in different locations depending on your operating system:

      Linux system : /etc/docker/daemon.json

      Windows : C:\ProgramData\docker\config\daemon.json

      MacOS : go to the whale in the taskbar > Preferences > Daemon > Advanced.

Example: The daemon.json file would look like this after editing :

1 2 3 4 5 { ... "bip": "172.26.0.1/16" }

After including the bip attribute in the file, you will need to restart the docker service:

1 sudo systemctl restart docker

Now the dind, or docker in docker, will no longer have a conflict in routing.

Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.