Docker 17
撰写 | Compose

docker-compose exec

docker-compose exec

Usage: exec [options] SERVICE COMMAND [ARGS...] Options: -d Detached mode: Run command in the background. --privileged Give extended privileges to the process. -u, --user USER Run the command as this user. -T Disable pseudo-tty allocation. By default `docker-compose exec` allocates a TTY. --index=index index of the container if there are multiple instances of a service [default: 1]

这相当于docker exec。使用此子命令,您可以在服务中运行任意命令。命令默认分配一个 TTY ,所以你可以做例如docker-compose exec web sh获得交互式提示。

fig, composition, compose, docker, orchestration, cli, exec