IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 系统运维 -> [docker]-docker-compose通过healthcheck判断容器状态并依次启动 -> 正文阅读

[系统运维][docker]-docker-compose通过healthcheck判断容器状态并依次启动

基础镜像已经打好 需要安装curl命令以便健康检查

看到以前的资料说是3版本废弃了depend下的condition,自己去使用和查资料的时候好像修复了。因为wait-for-it.sh这个实在是太难用了。使用condition需要确保镜像里有对应的命令,如curl

version: '3'
services:
  mysql:
    hostname: mysql
    image: 10.10.3.5/cta/mysql_base:01
    container_name: mysql
    volumes:
      - ./mysql/mysql.cnf:/etc/mysql/conf.d/mysql.cnf
      - ./mysql/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf
      - ./mysql/init:/docker-entrypoint-initdb.d/
      #- ./mysql/data:/var/lib/mysql
    privileged: true
    network_mode: "host"
    environment:
      - MYSQL_ROOT_PASSWORD=123
      - TZ=Asia/Shanghai
      - LANG=en_US.UTF-8
    healthcheck:
    # mysqladmin -uroot -p123  ping -h127.0.0.1
      test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
#      test: [ "CMD", "mysqladmin","-u","root","-p","123" ,"ping", "-h", "127.0.0.1" ]
      timeout: 45s
      interval: 10s
      retries: 10


  nginx:
    hostname: nginx
    image: nginx:1.20.2
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx/platform.conf:/etc/nginx/conf.d/platform.conf
      - ./nginx/svrshell:/root/svrshell
      - ./nginx/aiviewer:/root/aiviewer
# 增加cta
      - ./nginx/dwcta:/root/dwcta
# 增加input挂载
      - /data1/inputdata:/data1/inputdata
    container_name: nginx
    privileged: true
    network_mode: "host"
    environment:
      - TZ=Asia/Shanghai
      - LANG=en_US.UTF-8


  zk:
# zookeeper  修改了zoo.cfg的data和datalog路径 /opt/zk1/zookeeper-3.4.10
    hostname: zk
    image: 10.10.3.5/cta/zookeeper:3.4.10
    healthcheck:
#      test: ["CMD-SHELL", "curl -sS 127.0.0.1:2181 || exit 1"]
      test: ["CMD-SHELL", "echo 'ruok' | curl -s telnet://localhost:2181 || exit 1"]
      interval: 1m30s
      timeout: 10s
      retries: 3
      start_period: 40s
    depends_on:
      mysql:
        condition: service_healthy
        # condition: service_started
    volumes:
      - ./zk/zoo.cfg:/conf/zoo.cfg
#      - /opt/zk1/zookeeper-3.4.10/data:/data
#      - /opt/zk1/zookeeper-3.4.10/datalog:/datalog
    container_name: zk
    privileged: true
    network_mode: "host"
 #   ports:
 #     - 2181:2181

  es_python:
    hostname: es_python
    image: es_python:1.1
    volumes:
      - /data1/es_data:/usr/share/elasticsearch/data
    container_name: es_python
    privileged: true
    network_mode: "host"
    environment:
      - TZ=Asia/Shanghai
      - LANG=en_US.UTF-8

# 应用
  aiserverconfig:
# 20882 11383
    hostname: aiserverconfig
    image: 10.10.3.5/cta/aiserverconfig-cta_1215_20220112_002:latest
    healthcheck:
      test: ["CMD-SHELL", "curl -sS 127.0.0.1:11383 || exit 1"]
      interval: 1m30s
      timeout: 10s
      retries: 3
      start_period: 40s
    depends_on:
      mysql:
        condition: service_healthy
      zk:
        condition: service_healthy
    volumes:
      - /etc/sign.conf:/etc/sign.conf
      - /data1/container-root/aiserverconfig/log:/root/aiserverconfig/log
# 增加input挂载
      - /data1/inputdata:/data1/inputdata
    container_name: aiserverconfig
    privileged: true
    network_mode: "host"

  aiserver:
# 20880 11381
    hostname: aiserver
    image: 10.10.3.5/cta/aiserver-cta_1215_20220112_002:latest
    healthcheck:
      test: ["CMD-SHELL", "curl -sS 127.0.0.1:11381/aiserver/ai/v1/echo || exit 1"]
      interval: 1m30s
      timeout: 10s
      retries: 3
      start_period: 40s
    depends_on:
      mysql:
        condition: service_healthy
      zk:
        condition: service_healthy
      aiserverconfig:
        condition: service_healthy
    volumes:
      - /etc/sign.conf:/etc/sign.conf
      - /data1/container-root/aiserver/log:/root/aiserver/log
# 增加input挂载
      - /data1/inputdata:/data1/inputdata
    container_name: aiserver
    privileged: true
    network_mode: "host"

  pacsserver:
# 20881 22222 11380
    hostname: pacsserver
    image: 10.10.3.5/cta/pacsserver-cta_1215_20220112_002:latest
    healthcheck:
      test: ["CMD-SHELL", "curl -sS 127.0.0.1:11384/pacs/v2/dicom/echo || exit 1"]
      interval: 1m30s
      timeout: 10s
      retries: 3
      start_period: 40s
    depends_on:
      mysql:
        condition: service_healthy
      zk:
        condition: service_healthy
      aiserverconfig:
        condition: service_healthy
      aiserver:
        condition: service_healthy
    volumes:
      - /etc/sign.conf:/etc/sign.conf
      - /data1/container-root/pacsserver/log:/root/pacsserver/log
# 增加input挂载
      - /data1/inputdata:/data1/inputdata
    container_name: pacsserver
    privileged: true
    network_mode: "host"

  platform:
# 11380 11345
    hostname: platform
    image: 10.10.3.5/cta/platform-cta_1215_20220112_002:latest
    healthcheck:
      test: ["CMD-SHELL", "curl -sS 127.0.0.1:11380/echo || exit 1"]
      interval: 1m30s
      timeout: 10s
      retries: 3
      start_period: 40s
    depends_on:
      mysql:
        condition: service_healthy
      zk:
        condition: service_healthy
      aiserverconfig:
        condition: service_healthy
      aiserver:
        condition: service_healthy
    volumes:
      - /etc/sign.conf:/etc/sign.conf
      - /data1/container-root/platform/log:/root/platform/log
# 增加input挂载
      - /data1/inputdata:/data1/inputdata
    container_name: platform
    privileged: true
    network_mode: "host"

  ocrsvr:
# 28800
    hostname: ocrsvr
    image: 10.10.3.5/cta/ocrsvr-cta_1215_20220112_002:latest
    depends_on:
      mysql:
        condition: service_healthy
      zk:
        condition: service_healthy
      aiserverconfig:
        condition: service_healthy
      aiserver:
        condition: service_healthy
    volumes:
      - /etc/sign.conf:/etc/sign.conf
      - /data1/container-root/ocrsvr/log:/root/ocrsvr/log
# 增加input挂载
      - /data1/inputdata:/data1/inputdata
    container_name: ocrsvr
    privileged: true
    network_mode: "host"

  lung:
# 20880 11381
    hostname: lung
    image: 10.10.3.5/cta/lung-cta_1215_20220112_002:latest
    depends_on:
      mysql:
        condition: service_healthy
      zk:
        condition: service_healthy
      aiserverconfig:
        condition: service_healthy
      aiserver:
        condition: service_healthy
    volumes:
      - /etc/sign.conf:/etc/sign.conf
      - /data1/container-root/lung/log:/root/lung/log
# 增加input挂载
      - /data1/inputdata:/data1/inputdata
      - /tmp/.X11-unix:/tmp/.X11-unix
    container_name: lung
    privileged: true
    network_mode: "host"
    environment:
      - NVIDIA_DRIVER_CAPABILITIES=all
      - DISPLAY
      - XAUTHORITY
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

启动顺序如下 需要depend的容器为healthy才会启动下一个

重启策略

    deploy:
      restart_policy:
        condition: always
  系统运维 最新文章
配置小型公司网络WLAN基本业务(AC通过三层
如何在交付运维过程中建立风险底线意识,提
快速传输大文件,怎么通过网络传大文件给对
从游戏服务端角度分析移动同步(状态同步)
MySQL使用MyCat实现分库分表
如何用DWDM射频光纤技术实现200公里外的站点
国内顺畅下载k8s.gcr.io的镜像
自动化测试appium
ctfshow ssrf
Linux操作系统学习之实用指令(Centos7/8均
上一篇文章      下一篇文章      查看所有文章
加:2022-03-22 21:01:04  更:2022-03-22 21:01:36 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/16 0:28:46-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码