🔍 What are Docker Compose plugins?
The Docker Compose plugin (docker compose
) is an integrated plugin in the Docker engine that replaces the existing standalone docker-compose
tool. It was introduced in Docker v20.10 in 2021 and is fully integrated with the docker
CLI. Unlike the original docker-compose
(based on Python), it is developed in the Go language, which significantly improves performance and compatibility.
# Compare old vs new commands
docker-compose up -d # Legacy (standalone)
docker compose up -d # modern (plugin)
```bash
### 🌟 Background: Why a plugin?
1. **Performance improvement**: Go native compilation makes it 2-3x faster to run
2. integrated management: Provides the same experience as the `docker` CLI
3. version compatibility: automatically synchronizes with the Docker engine version
4. extensibility: full support for V2 compose files (`.yaml`)
5. enhanced security: No root privileges required (previously required sudo)
---.
### ⚙️ Installation Guide (on Linux)
#### 1. Update Docker Engine (v20.10+)
```bash
sudo apt update && sudo apt upgrade docker-ce
2. Install the Compose plugin
sudo apt install docker-compose-plugin
3. Verify the installation
docker compose version
# Example output: Docker Compose version v2.23.0
> 💡 Windows/macOS: Automatically included when installing the latest version of Docker Desktop
—]
🚀 Core Usage & Examples
Basic command structure
docker compose [COMMAND] [OPTIONS]
1. Run a service (e.g. Nginx + MySQL)
# docker-compose.yaml
services:
web:
image: nginx:alpine
ports:
- "80:80"
db:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: secret
docker compose up -d # Run in the background
2. Manage environment-specific settings
# For development
docker compose -f docker-compose.dev.yaml up
# For production
docker compose -f docker-compose.prod.yaml up
3. Check the live logs
docker compose logs -f web # stream web service logs
—]
🆚 Plugin vs standalone differences
Features | Plugin (docker compose ) |
Standalone (docker-compose ) |
|
---|---|---|---|
Execution speed | ⚡️ more than 2x faster | Relatively slow | |
CLI integration | ✅ Fully integrated with docker |
❌ Runs separately | |
Permissions required | 🛡️ No root required | ⚠️ Mostly sudo required | |
Compose file versions | 📄 full support for v2/v3 | v1/v2 support | |
Extensions | 🔌 Plugin system support | ❌ Not supported | ❌ Not supported |
—.
🔥 Advanced Utilization Tips
1. Group services into profiles
services:
frontend:
profiles: ["front"]
image: nginx
analytics:
profiles: ["monitoring"]
image: prometheus
# at runtime: docker compose --profile front up
2. Improve dependency control
services:
app:
depends_on:
db:
condition: service_healthy
db:
healthcheck:
test: ["CMD", "mysqladmin", "ping"]
3. Local build + caching
docker compose build --no-cache # rebuild ignoring cache
—]
⚠️ Notes & Migration
- volume naming changes: automatically add project name prefix (
_
) - command language differences:
docker-compose
→docker compose
(dash removed) - version compatibility:
version:"3.8"
must be specified when using legacy v1 files - error handling: Update Docker when
ERROR: .Illegal instruction
occurs
—.
🎯 Conclusion: Why should you use the plugin?
- Productivity: Simplify your workflow with a unified CLI
- Performance: Significant speed difference when deploying large-scale services
- Future-proofing: Docker’s official roadmap signals the end of standalone support
- Ecosystem integration: Synergies with BuildKit, Scan, and extension plugins
> 📢 As of 2024, all new projects are strongly encouraged to use the docker compose plugin! Existing projects can also migrate gradually.
# migrate in one step
alias docker-compose="docker compose" # add alias to shell
```bash
Start a new era of container orchestration with the Docker Compose plugin! 🐳💨