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”.
How?

I have tried using external_links without luck.
Any suggestions would be appreciated.

  • Version error when installing docker toolbox on OSX
  • How to configure NGINX routes?
  • Failed to find a usable hardware address from the network interfaces
  • Using Gitlab CD and Docker
  • Docker number of lines in terminal changing inside docker
  • ElasticBeanstalk: storing a bullet proof docker container
  • Can't start docker with postgres
  • Manage docker environment for Swarm running cluster with UPC
  • Docker Maven plugin: how to specify shm size when running a container
  • How to debug the creation of docker container container in Vagrant
  • How can I make docker-compose build an image from a remote git repository?
  • Docker : How to change the location of directory images in Docker?
  • 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:

    networks: default:
    external:
    name: myapp_net

    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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.