Docker Community Forums

Share and learn in the Docker community.

Docker compose for development splitting web and api service containers - recommendation needed

I’ve been looking for a good way to spin up a development environment with docker compose that allows for separate web and api service containers so that the web application can call into the api service over http.


  1. I would like the set up to be dead simple so that developers just run compose ‘build’ and then ‘up’ without having to muck about with their local machine configuration on mac and linux.

  2. all configuration is passed through environment variables both on the api server and in the web application (eg. we are transferring a subset of the the environment variables verbatim into the web application’s javascript). In production, the environment variables would be set to actual services instead of references to services from the docker compose file.

Here’s our current docker-compose.yml:

version: "2"
    image: app/admin-web:development
      context: ./admin-web
      dockerfile: Dockerfile.development
        - ./admin-web:/home/nodejs/app
      - "3000:3000"
      - admin_api
      - ADMIN_API_URL=http://admin_api:3001

    image: app/admin-api:development
      context: ./admin-api
      dockerfile: Dockerfile.development
        - ./admin-api:/home/nodejs/app
      - "3001:3000"

Using ADMIN_API_URL from the web app, the problem is that because the http calls from the web application are being made from the browser, the network aliasing to admin_api doesn’t resolve using the networking aliases set up by docker.

Any recommendations for our development environment given the requirements of 1) zero additional developer machine configuration 2) using environment variables?

Thank you in advance!