美文网首页
docker-compose的一些进阶用法(补充中)

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

作者: 玄德公笔记 | 来源:发表于2021-12-28 16:10 被阅读0次

@[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的一些进阶用法(补充中)

      本文链接:https://www.haomeiwen.com/subject/ndifaltx.html