docker-compose的一些进阶用法(补充中)

@[toc]

前言

相关文档:
《docker-compose的yml文件中常用选项》
《docker-compose网络》
《docker-compose限制容器cpu和内存》
《docker-compose的build使用》

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

你可能感兴趣的:(docker-compose的一些进阶用法(补充中))