Docker Compose

Difficulty: Beginner

Question

What is Docker Compose and why is it used?

Answer

Docker Compose is a tool for defining and running multi-container applications. You use a YAML file to configure your application's services, networks, and volumes, then start them all with a single command.

Code examples

Simple docker-compose.yml

version: '3.8'
services:
  web:
    build: .
    ports:
      - "5000:5000"
  redis:
    image: "redis:alpine"

This defines a web service and a redis database that can talk to each other automatically.

Key points

Concepts covered

Orchestration, YAML, Microservices