重启服务器后,容器启动顺序问题

1. 添加健康检测

    healthcheck:
      test: ["CMD", "sh", "-c", "nc -z mysql 3306 || exit 1"]
      interval: 10s
      retries: 3
      timeout: 5s

编辑应用参数,高级设置,勾选编辑compose,填入以下,然后重建,其中mysql主机名按需修改

version: '3'
services:
  answer:
    container_name: ${CONTAINER_NAME}
    restart: always
    networks:
      - 1panel-network
    ports:
      - "${PANEL_APP_PORT_HTTP}:80"
    volumes:
      - "./data:/data"
    image: answerdev/answer
    healthcheck:
      test: ["CMD", "sh", "-c", "nc -z mysql 3306 || exit 1"]
      interval: 10s
      retries: 3
      timeout: 5s
    labels:  
      createdBy: "Apps"

networks:  
  1panel-network:  
    external: true

2. 安装autoheal

通过autoheal自动重启不健康应用。

手动安装或者从这里添加安装

1 个赞