Base de Conhecimento

Getting Started with Docker Compose

Docker Compose lets you define and run multi-container applications with a single YAML file. This assumes Docker is already installed (see our Docker install guide).

1. Verify Compose is available

docker compose version

2. Create a docker-compose.yml file

services:
  web:
    image: nginx:latest
    ports:
      - "8080:80"
    volumes:
      - ./site:/usr/share/nginx/html
  db:
    image: postgres:16
    environment:
      POSTGRES_PASSWORD: example
    volumes:
      - dbdata:/var/lib/postgresql/data

volumes:
  dbdata:

3. Start the stack

docker compose up -d

4. Common commands

docker compose ps        # list running services
docker compose logs -f   # follow logs
docker compose down      # stop and remove containers

Compose is ideal for local development and simple production stacks where all services run on one host.

Esta resposta foi útil?

0 Os usuários acharam isso útil

Powered by WHMCompleteSolution