How can I link a container spawned by one compose file to a container which is spawned by another compose file?
Say that we have two compose files. Composefile “A” and “B”.
They are both spawning containers.
One of the containers in composefile “A” needs to be linked with composefile “B”.
I have tried using external_links without luck.
Any suggestions would be appreciated.
One Solution collect form web for “How can I link a container spawned by one compose file to a container which is spawned by another compose file?”
With the docker compose v2 syntax you can put them all on the same docker network by specifying the same default network in both docker compose files:
It may give you a warning telling you the network doesn’t exist in which case you just run the command it gives in the warning. After this containers from both compose files should be able to access each other.
There’s an example of it working in one of my projects here.