Docker Community Forums

Share and learn in the Docker community.

Docker Container Cannot Access Another Container with FQDNs

I have set up two containers on an Ubuntu 20.4 server with NGINX as follows:

Both containers are accessible from the outside world and even I can access third-party APIs in the container. However, when I am trying to access container 1 from container 2 using its fully qualified domain, it times out.

I installed curl inside the container it seems that it cannot reach out to the host’s public IP address. What would be an appropriate solution? You may wonder why I am doing this because eventually these 2 services will be hosted on completely independent servers.

BTW, I posted this question on StackOverFlow and I couldn’t put all images because I am a new user.

If the fqdn is resolveable by the resolver on your host, and you did not override the containes dns resolvers yourself, it should work as is.

You can troubleshoot network issues with


* `$ docker run -it --net container:<container_name> nicolaka/netshoot`

If you replace <container_name> with the id or container name of container 2 in above example, you should get an interactive terminal in the netshoot container, that hooks into the network namespace of container 2 (=uses network interface of container 2). You can use it for further diagnostics.

1 Like