Skip to Content

Docker Compose — Your Entire System in One File

Docker Compose

Your entire system in one file

Docker Compose lets you define and run multi-container applications with a single YAML file. Instead of running separate docker commands for each service, you describe everything in one place and start it all with one command.

Why Docker Compose

Single Source of Truth

All your services, networks, and volumes are defined in one file. No more remembering complex docker run commands.

Reproducible Deployments

The same file works everywhere. Share it with your team, commit it to Git, use it in CI/CD.

Service Dependencies

Define which services depend on which. Compose starts them in the correct order.

Anatomy of docker-compose.yml

docker-compose.yml
services:
  db:
    image: postgres:16
    environment:
      POSTGRES_USER: odoo
      POSTGRES_PASSWORD: odoo_secret
      POSTGRES_DB: postgres
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: unless-stopped

  odoo:
    image: odoo:18
    depends_on:
      - db
    ports:
      - "8069:8069"
    environment:
      HOST: db
      USER: odoo
      PASSWORD: odoo_secret
    volumes:
      - odoo-data:/var/lib/odoo
    restart: unless-stopped

volumes:
  pgdata:
  odoo-data:

Key Sections Explained

1

services

Each service is a container. Here we define two: db for PostgreSQL and odoo for the application.

2

image

Which Docker image to use. The tag after the colon specifies the version.

3

environment

Environment variables passed into the container. Used for database credentials, host names, and configuration.

4

volumes

Named volumes that persist data. Defined per service and declared globally at the bottom.

5

depends_on

Tells Compose to start the database before the application.

6

restart

The unless-stopped policy restarts containers automatically after crashes or server reboots.

Essential Commands

Daily commands
docker compose up -d          # Start all services in background
docker compose ps              # List running containers
docker compose logs -f         # Follow live logs
docker compose down            # Stop and remove containers
docker compose pull            # Pull latest images

docker compose down vs stop

The down command removes containers and networks. The stop command only stops them. Use stop for temporary pauses, down for clean restarts. Volumes are preserved in both cases.

One File, Full Stack

Docker Compose transforms a complex multi-service deployment into a single readable file and a single command. This is the foundation of your Varyshop deployment.

Pochopte docker-compose.yml a napište jeden, který spustí Varyshop s PostgreSQL, včetně volumes a proměnných prostředí.

Rating
0 0

There are no comments for now.

to be the first to leave a comment.