Auto-sync: 2026-04-22 04:02
This commit is contained in:
56
wiki/concepts/Docker-Compose.md
Normal file
56
wiki/concepts/Docker-Compose.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# Docker Compose
|
||||
|
||||
## Description
|
||||
Docker Compose 是 Docker 官方提供的多容器 Docker 应用定义和运行工具。通过 `docker-compose.yml`(或 `compose.yaml`)配置文件,使用 YAML 格式声明式定义多容器服务的网络、卷、端口映射、环境变量等,实现一键部署复杂应用。
|
||||
|
||||
## Version
|
||||
- **V1 (独立包)**:`docker-compose` 命令(已弃用)
|
||||
- **V2 (插件)**:`docker compose` 命令(当前主流),通过 `docker-compose-plugin` 包安装,集成到 Docker CLI
|
||||
|
||||
## V1 vs V2 Command Reference
|
||||
| V1 (独立包) | V2 (插件) |
|
||||
|------------|-----------|
|
||||
| `docker-compose up -d` | `docker compose up -d` |
|
||||
| `docker-compose ps` | `docker compose ps` |
|
||||
| `docker-compose down` | `docker compose down` |
|
||||
| `docker-compose -f xxx.yml config` | `docker compose -f xxx.yml config` |
|
||||
|
||||
## Core Concepts
|
||||
- **Services**: 定义每个容器服务(镜像、构建、端口、卷、环境变量)
|
||||
- **Volumes**: 命名数据卷,持久化容器数据
|
||||
- **Networks**: 容器网络配置(bridge、host、overlay)
|
||||
- **Version**: `version: '3.8'` 为当前主流版本规范
|
||||
|
||||
## Example
|
||||
```yaml
|
||||
version: '3.8'
|
||||
services:
|
||||
it-tools:
|
||||
image: corentinth/it-tools:latest
|
||||
container_name: it-tools
|
||||
restart: unless-stopped
|
||||
stdin_open: true
|
||||
tty: true
|
||||
ports:
|
||||
- "8999:80"
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 128M
|
||||
```
|
||||
|
||||
## Used By
|
||||
- [[用docker安装it-tools]]
|
||||
- [[用docker安装transmission]]
|
||||
- [[Navidrome]]
|
||||
- [[Jellyfin]]
|
||||
- [[RSSHub]]
|
||||
|
||||
## Related Concepts
|
||||
- [[Docker-Image]]
|
||||
- [[Docker-Save]]
|
||||
- [[Docker-Load]]
|
||||
- [[容器资源限制]]
|
||||
- [[容器重启策略]]
|
||||
- [[端口映射]]
|
||||
- [[桥接网络]]
|
||||
Reference in New Issue
Block a user