Start by using a custom bridge network. This way you do not need to use --link , which is considered deprecated, and the containers will be able to communicate using their names. This is what the bridge network does not provide by default.
From: Docker Docs
Differences between custom bridges and the default bridge
- Custom bridges provide automatic DNS resolution between containers.
Secondly, you can do this “manually” by running docker commands in the appropriate order / depending on your case, but, as Sebastian showed in the docker-compose file, it’s much easier to handle this.
source share