Files
nexus/wiki/concepts/Docker-Compose.md
2026-04-28 16:03:03 +08:00

33 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Docker Compose"
type: concept
tags: [docker, devops, orchestration]
last_updated: 2026-04-23
---
## Overview
Docker Compose 是一个用于定义和运行多容器 Docker 应用的工具。通过 YAML 文件(`docker-compose.yml`)声明服务、网络、卷等配置,一条命令即可启动整套应用栈。
## Key Commands
```bash
docker-compose up -d # 启动服务(后台)
docker-compose down # 停止并移除容器
docker-compose restart # 重启服务
```
## Key Concepts
- **Services**: 每个容器定义为一个 service
- **Network Mode**: 可使用 `network_mode: host` 将容器网络直接绑定到宿主机
- **Environment Variables**: 通过 `environment` 字段注入环境变量(如 `YOUTUBE_KEY``HTTP_PROXY`
- **Volumes**: 通过 `volumes` 字段将宿主机文件/目录挂载到容器内
- **Restart Policy**: `restart: unless-stopped` 确保容器在宿主机重启后自动恢复
## Usage in This Wiki
- RSSHub 部署配置使用 Docker Compose 作为主机上的容器编排工具
- n8n、Portainer、Jellyfin 等服务均通过 Docker Compose 管理
## Aliases
- docker-compose
- Docker Compose
- docker compose