Docker Compose

205 阅读1分钟

记录一下Docker Conpose 的一些配置

# API版本
version: "3.3"
# 服务列表
services:
# 服务名称
    app:
        # 服务主机名
        hostname: app
        # 重启策略
        restart: always
        # 容器名称
        container_name: app
        # 容器镜像
        image: app:1.0.0
        # 网络模式 host 和主机使用同一网络,此时容器端口外部将直接可以访问
        network_mode: host
        # 健康检查
        healthcheck:
          # 检查命令
          test: ["CMD","curl","http://localhost:8080","-X","GET"]
          # 检测时间
          interval: 30s
          # 超时时间
          timeout: 10s
          # 检查次数
          retries: 10
          # 容器启动多久后开始检查
          start_period: 30s
        # 服务依赖
        depends_on:
          # 被依赖服务
          mysql:
            # 策略
            condition: service_healthy
        # 容器环境变量配置
        environment:
          # 左侧为Key
          # 右侧为Value
          - TZ=Asia/Shanghai
        # 容器端口映射
        ports:
          - "8080:8080"
        # 添加容器hosts,配置本地域名解析
        extra_hosts:
          # 左侧为域名
          # 右侧为IP
          - 'mysql.leadal.com:127.0.0.1'
        # 自定义容器启动命令
        command: /bin/bash start-server.sh
        # 存储 or 文件挂载
        volumes:
          # 左侧为宿主机路径
          # 右侧为容器路径
          - /nas/conf/armor:/opt/netiler/conf