diff --git a/src/tools/docker-compose-memo/docker-compose.md b/src/tools/docker-compose-memo/docker-compose.md index cdd8191e..98f7f77f 100644 --- a/src/tools/docker-compose-memo/docker-compose.md +++ b/src/tools/docker-compose-memo/docker-compose.md @@ -1,10 +1,10 @@ -Docker Compose is a powerful tool for defining and running multi-container Docker applications. It uses a YAML file (`docker-compose.yml`) to configure application services, networks, volumes, and more. This file allows developers to declaratively describe infrastructure and dependencies, making it easier to manage complex environments. +Docker Compose is a powerful tool for defining and running multi-container Docker applications. It uses a YAML file (`compose.yaml`) to configure application services, networks, volumes, and more. This file allows developers to declaratively describe infrastructure and dependencies, making it easier to manage complex environments. Whether you're building a local dev stack or deploying to production, Compose simplifies orchestration and keeps your configuration readable and version-controlled. ## ๐Ÿ“ File Name ```yaml -docker-compose.yml +compose.yaml ``` ### โœ… YAML Formatting Rules @@ -18,7 +18,6 @@ docker-compose.yml ## ๐Ÿงฑ Basic Structure ```yaml -version: '3.8' # Compose file version services: service_name: image: image_name:tag @@ -231,22 +230,22 @@ env_file: ## ๐Ÿงน Clean Up ```bash -docker-compose down # Stop and remove containers, networks, volumes -docker-compose down -v # Also remove named volumes +docker compose down # Stop and remove containers, networks, volumes +docker compose down -v # Also remove named volumes ``` ## ๐Ÿš€ Commands | Command | Description | |--------|-------------| -| `docker-compose up` | Start services | -| `docker-compose up -d` | Start in detached mode | -| `docker-compose down` | Stop and remove services | -| `docker-compose build` | Build images | -| `docker-compose ps` | List containers | -| `docker-compose logs` | View logs | -| `docker-compose exec ` | Run command in container | -| `docker-compose config` | Validate and view config | +| `docker compose up` | Start services | +| `docker compose up -d` | Start in detached mode | +| `docker compose down` | Stop and remove services | +| `docker compose build` | Build images | +| `docker compose ps` | List containers | +| `docker compose logs` | View logs | +| `docker compose exec ` | Run command in container | +| `docker compose config` | Validate and view config | ## ๐Ÿง  Mounting GPU / iGPU @@ -282,7 +281,7 @@ services: ## ๐Ÿ”„ Compose vs Swarm YAML Differences -| Feature | Docker Compose (`docker-compose.yml`) | Docker Swarm (`stack.yml`) | +| Feature | Docker Compose (`compose.yaml`) | Docker Swarm (`stack.yml`) | |--------------------|----------------------------------------|-----------------------------| | `restart` | โœ… Supported | โŒ Not supported | | `depends_on` | โœ… Supported | โŒ Not supported | @@ -292,7 +291,7 @@ services: | `configs`/`secrets`| โŒ Ignored | โœ… Supported | | `healthcheck` | โœ… Supported | โœ… Supported | -> ๐Ÿง  **Tip:** Use `docker-compose.yml` for local development and `stack.yml` for Swarm deployments. +> ๐Ÿง  **Tip:** Use `compose.yaml` for local development and `stack.yml` for Swarm deployments. ## ๐Ÿงฌ Profiles (Compose v3.9+) @@ -339,9 +338,8 @@ Docker Compose and Docker Swarm both use YAML files to define services, but they ### ๐Ÿงฉ Key Differences in YAML Structure -| Feature | Compose (`docker-compose.yml`) | Swarm (`stack.yml`) | +| Feature | Compose (`compose.yaml`) | Swarm (`stack.yml`) | |----------------------|-------------------------------|----------------------| -| `version:` | โœ… Required (e.g. `3.8`) | โŒ Optional / Ignored | | `build:` | โœ… Supported | โŒ Ignored | | `restart:` | โœ… Supported | โŒ Ignored | | `depends_on:` | โœ… Supported | โŒ Ignored | @@ -455,7 +453,7 @@ Swarm requires external volumes to be pre-created on all nodes. | Restart policies | โœ… | โœ… (via `deploy`) | | Service dependencies | โœ… | โŒ | -> ๐Ÿงญ **Tip:** Use `docker-compose.yml` for development and `stack.yml` for Swarm. You can split your configuration into multiple files or use tools like `kompose` to convert Kubernetes manifests. +> ๐Ÿงญ **Tip:** Use `compose.yaml` for development and `stack.yml` for Swarm. You can split your configuration into multiple files or use tools like `kompose` to convert Kubernetes manifests. ## ๐Ÿ“š Resources