...

/

Launch a Development Environment with Docker Compose

Launch a Development Environment with Docker Compose

Learn how to launch your app with Docker Compose.

Docker Compose

Docker Compose can override the image’s default production settings to launch a container in development mode. We will use the following docker-compose.yml:

Press + to interact
version: '3'
services:
nodehello:
environment:
- NODE_ENV=development
build:
context: ./
dockerfile: Dockerfile
container_name: nodehello
volumes:
- ./:/home/node/app
ports:
- "3000:3000"
- "9229:9229"
command: /bin/sh -c 'npm install && npm run debug'

Before we referenced a specific image: from Docker Hub. In this file, a build: option is used to create an image from a Dockerfile:

  • The context: is the relative path to the location of your Dockerfile.
  • The dockerfile: is the name of your Dockerfile.

Additionally:

  1. The container name is set to nodehello.
  2. The NODE_ENV environment variable is set to development.

    Sometimes, setting the NODE_ENV is not overridden with Dockerfile (in our case it’s set to production). It’s because, at the building of the image, the environment variables are set as specified in Dockerfile. To ...