Docker Compose 常用指令
# Docker Compose 常用指令
# 启动、停止、重启 等常用指令
# 启动 -f 指定文件 -d 指的是后台启动
docker-compose -f docker-compose-redis.yml up -d
# 停止
docker-compose -f docker-compose-redis.yml stop
# 停止并删除服务(可能会切断容器间的网络)
docker-compose -f docker-compose-redis.yml down
# 查看日志
docker-compose -f docker-compose-redis.yml logs
# 验证docker-compose.yml 配置文件是否正确,正确的情况下不会输出任何东西
docker-compose -f docker-compose-redis.yml config -q
# 重启
docker-compose -f docker-compose-redis.yml restart
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
# 参数说明
docker-compose [-f <arg>...] [options] [COMMAND] [ARGS...]
1
options指令 | 说明 |
---|---|
build | Build or rebuild services |
config | Validate and view the Compose file |
create | Create services |
down | Stop and remove resources |
events | Receive real time events from containers |
exec | Execute a command in a running container |
help | Get help on a command |
images | List images |
kill | Kill containers |
logs | View output from containers |
pause | Pause services |
port | Print the public port for a port binding |
ps | List containers |
pull | Pull service images |
push | Push service images |
restart | Restart services |
rm | Remove stopped containers |
run | Run a one-off command |
scale | Set number of containers for a service |
start | Start services |
stop | Stop services |
top | Display the running processes |
unpause | Unpause services |
up | Create and start containers |
version | Show version information and quit |
上次更新: 2022/12/29, 19:53:09