Docker Community Forums

Share and learn in the Docker community.

Connecting two Compose applications


(Karim Ratib) #1

I am using two separate apps locally, each having its own Compose file. Now I’d like app B to access an API from app A (which happens to be exposed on locahost:3000). How can I do that, preferably with no change to either Compose file?


(Karim Ratib) #2

I ended up changing the Compose file for app A, adding an external network entry:

networks:
  dev:
  out:
    external:
      name: "${NETWORK:-check_dev}"

The default external network name is the same as the internal one - this way I don’t require the $NETWORK env var to be present.

Now app A (which exposes the API) can be exposed to app B that wants to consume the API. B simply refers to the service name of the API as defined by A.