build --no-cache # Rebuild images pull # Pull latest images push # Push built images
version: '3.8' services: api: build: ./app ports: - "3000:3000" environment: - DB_HOST=db - REDIS_HOST=redis depends_on: db: condition: service_healthy healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3000/health"] interval: 30s a developer's essential guide to docker compose pdf
One command to spin up a dev environment identical to production dependencies (databases, caches, queues). 2. Core Concepts | Concept | Description | |---------|-------------| | Service | A containerized application (e.g., web app, database) | | Network | Isolated communication layer between services | | Volume | Persistent data storage (survives container restarts) | Default behavior: All services in the same Compose project automatically join a default network and can reach each other using their service name as hostname. 3. The docker-compose.yml File – Anatomy version: '3.8' # Latest stable version (March 2025) services: app: build: ./app ports: - "3000:3000" environment: - NODE_ENV=development depends_on: - db - redis build --no-cache # Rebuild images pull # Pull
docker run ... (20 flags) docker network create ... docker volume create ... → Error-prone, slow, non-repeatable. docker volume create
redis: image: redis:alpine ports: - "6379:6379"