Skip to main content

04 docker-composer的基本知识

1 docker-compose启动执行多行命令

docker-compose启动执行多行命令
version: '3'

services:
hyperf:
image: hyperf:latest
command:
- /bin/sh
- -c
- |
composer install
php bin/hyperf.php start # <-- command1
php bin/hyperf.php TryCreateDatabase:true # <-- command2

3 docker-compose构建镜像时的环境变量配置

以下是在建构前,设置代理的环境变量
version: '3'

services:
hyperf:
image: hyperf:latest
build:
context: .
dockerfile: ./hyperf/Dockerfile
args:
- http_proxy=http://127.0.0.1:1087
- https_proxy=http://127.0.0.1:1087
- HTTP_PROXY=http://127.0.0.1:1087
- HTTPS_PROXY=http://127.0.0.1:1087
ports:
- "9501:9501"