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.

  • How to integrate Capistrano with Docker for deployment?
  • Docker run Error: Status 403 trying to pull repository Unable to access the repository:
  • How to allow incoming connection on a particular port from specific IP
  • Is it possible to launch a new Docker container from within a running Docker container using Docker Compose?
  • How to solve classcastexception of same class for ehcache
  • Mounting container volume from the hosts' drive?
  • Centos7 docker-py doesn't seem to be installed
  • ansible-container variables in playbook
  • docker-machine stop command kills all my containers
  • pip install letencrypt, hwo do I know which packages are needed?
  • Retain environment variable values for Symfony2 app development in Docker
  • Cannot trace error in python pcapy wrapper
  • 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.