ops-49 docker-compose常用字段详解
相关文档:
docker-compose的yml文件中常用选项:
https://blog.csdn.net/xingzuo_1840/article/details/122071489
docker-compose网络:
https://blog.csdn.net/xingzuo_1840/article/details/120182291
docker-compose限制容器cpu和内存:
https://blog.csdn.net/xingzuo_1840/article/details/120182356
docker-compose的build使用:
https://blog.csdn.net/xingzuo_1840/article/details/122071750
1.定义hosts
version: '3.7'
services:
minio1:
image: harbocto.xxx.com.cn/public/minio:RELEASE.2021-02-01T22-56-52Z
……
extra_hosts:
- "minio1:10.10.xxx.125"
- "minio2:10.10.xxx.126"
- "minio3:10.10.xxx.127"
- "minio4:10.10.xxx.131"
————————————————---------------------------
2.健康检查
version: '3.7'
services:
minio1:
image: harbocto.xxx.com.cn/public/minio:RELEASE.2021-02-01T22-56-52Z
……
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
————————————————
3. 指定MAC地址
mac_address: MAC地址
version: "3.1"
services:
coreservice:
container_name: core-service-003
image: java
ports:
- 8030:8000
- 8031:8001
- 8032:8002
mac_address: 00:16:3e:08:9f:8f
volumes:
- /data/coreservice003:/opt/coreservice
command: /opt/coreservice/start.sh
————————————————
4. 指定时区
4.1 方法一:变量指定(注意: 本方法是否生效要看镜像是否支持以变量指定时区)
version: "3.1"
services:
mysql:
image: harbocto.boe.com.cn/public/mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: xxxxxxx
MYSQL_DATABASE: devops
TZ: Asia/Shanghai
restart: always
ports:
- 3306:3306
volumes:
- ./data:/var/lib/mysql
4.2 方法二:挂载时区文件
version: "3.1"
services:
mysql:
image: harbocto.boe.com.cn/public/mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: xxxxxx
MYSQL_DATABASE: devops
TZ: Asia/Shanghai
restart: always
ports:
- 3306:3306
volumes:
- ./data:/var/lib/mysql
- /usr/share/zoneinfo/Asia/Shanghai:/usr/share/zoneinfo/Asia/Shanghai:ro
————————————————
5. 特权模式
version: "3.1"
services:
emqx:
image: "emqx/emqx:4.3.11"
container_name: "iot-emqx"
privileged: true
environment:
珊瑚海

浙公网安备 33010602011771号