Can't resolve Docker container names, have to use Docker IP address

Running Docker on my Synology NAS. My apps are all on the Bridge network. I can connect to an app from another app using their Docker IP address, but not the Docker container name. They are all using the default Bridge network. The obvious issue is if the containers are restarted and get a different IP address things will stop working, hence I would like to use the Container name.

I am relatively new to Docker and don’t understand how the DNS would work or how to troubleshoot this issue. Any suggestions? Thanks.

DNS resolution works only on custom bridge networks, but not on the default. Docker Compose creates a custom network by default calling it “default” in the compose yaml, but it is not required to define and it would be projectname_default in the list of docker networks and not “bridge”.

1 Like

Thank you for the explanation. So the only real solution here is to recreate all the Containers on a new custom bridge of the same name? Is there any way to get this working on the “bridge” network?

No, it won’t work on the dfault bridge network. At least not without recreating the containers and use the legacy links if that still works, but with custom networks, you don’t need to restart the container. You can just connect the networks to the containers

https://docs.docker.com/engine/reference/commandline/network_connect/

Oh, and I should also mention that recreating the containers should not be a problem if you create them properly.

Again, thanks for your help. Does App A then use appa_default, App B use appb_default or do i need to create a new custom network and use that across all apps that need to communicate to one another?

You need the containers to use a common network in order to be able to communicate. But if you read the documentation I shared, you will find the answer :slight_smile:

You can connect a container by name or by ID. Once connected, the container can communicate with other containers in the same network.

1 Like

Thanks, I saw that. I was just a bit confused as in the network dropdown in Docker I was only getting Bridge and App_default as networks. I’ll try and configure them using a script, not the GUI.