Course contentsShow
← Cloud and Infrastructure
Lesson 1056 of 2,98920. Docker in DepthFree lesson

Compose CLI Commands

Master docker-compose up, down, ps, logs, exec, and other commands for managing multi-container applications.

Compose CLI Commands

What you'll learn: How to control and inspect your multi-container applications using Docker Compose's essential command-line tools.

Core Idea

Docker Compose provides a powerful set of CLI commands to manage the entire lifecycle of your multi-container applications defined in your compose file. Think of these commands as the control panel for your application stack—starting, stopping, monitoring, and interacting with all your services at once.

Essential Commands

docker-compose up – Starts your entire application stack. Use -d for detached mode (runs in background). This reads your compose file, creates networks and volumes, then launches all services.

docker-compose down – Stops and removes all containers, networks created by up. Add --volumes to remove volumes too. It's your clean shutdown command.

docker-compose ps – Lists all running containers in your application, showing their status, ports, and names. Your quick health check.

docker-compose logs – Displays logs from all services. Add -f to follow logs in real-time, or specify a service name like logs web to view just one service.

docker-compose exec – Runs a command inside a running service container. Example: exec web sh opens a shell in the "web" service—perfect for debugging or manual tasks.

Other useful commands:

  • start/stop – Control containers without removing them
  • restart – Restart services
  • build – Rebuild service images
  • pull – Pull latest images for services

Why This Matters

These commands let you operate your entire application as a single unit rather than juggling individual container commands. You orchestrate complexity with simple, memorable commands.

Key Takeaway: Docker Compose CLI commands provide unified control over multi-container applications—up to start, down to stop, ps to inspect, logs to debug, and exec to interact with running services.