Docker Compose
compose.yaml
- name
- services
- volumes
- secret
- config
docker compose command
bash
# 启动服务
docker compose up
# 在后台启动
docker compose up -d
# 停止服务
docker compose stop
# 停止服务并销毁容器
docker compose down
# 停止服务并销毁一切,包括容器和持久卷
docker compose down --volumes
# The docker compose run command allows you to run one-off commands for your services.
# For example, to see what environment variables are available to the web service
docker compose run web env
# 指定配置文件
docker compose -f production.yml upEnvironment variables
The order of precedence (highest to lowest) is as follows:
- Set using
docker compose run -ein the CLI - Substituted from your shell
- Set using just the
environmentattribute in the Compose file - Use of the
-env-fileargument in the CLI - Use of the
env_fileattribute in the Compose file - Set using an
.envfile placed at base of your project directory - Set in a container image in the ENV directive. Having any
ARGorENVsetting in aDockerfileevaluates only if there is no Docker Compose entry forenvironment,env_fileorrun --env.
Profiles
If unassigned, the service is always started but if assigned, it is only started if the profile is activated.
类似SpringBoot的application.yaml中的profile