Labs ICT
Pro Login

The Compose File

Understanding the YAML configuration

The Compose File

The docker-compose.yml file defines your entire multi-container application.

Example Compose File


  version: '3.8'

  services:
    web:
      build: ./web
      ports:
        - "3000:3000"
      depends_on:
        - api
      environment:
        - API_URL=http://api:8080

    api:
      build: ./api
      ports:
        - "8080:8080"
      depends_on:
        - db
      environment:
        - DB_HOST=db
        - DB_PASSWORD=secret

    db:
      image: mysql:8
      volumes:
        - dbdata:/var/lib/mysql
      environment:
        - MYSQL_ROOT_PASSWORD=secret
        - MYSQL_DATABASE=myapp

  volumes:
    dbdata:

Compose File Structure