Docker
docker-compose 和 willfarrell/autoheal 不使用出口 2 重新啟動容器
docker-compose 不會重新啟動我的容器,即使它以退出程式碼 2 is 列出也是如此
docker-compose ps
。Name Command State Ports ----------------------------------------------------------------------------- app_autoheal_1 /docker-entrypoint autoheal Up (healthy) seafile /sbin/my_init -- /scripts/ ... Exit 2
它在
docker-compose.yaml
with中定義restart: always
。version: '3.4' services: autoheal: restart: always image: willfarrell/autoheal environment: - AUTOHEAL_CONTAINER_LABEL=all volumes: - /var/run/docker.sock:/var/run/docker.sock seafile: image: seafileltd/seafile-mc:latest restart: always container_name: seafile healthcheck: test: ["CMD-SHELL", "test $$(curl -k https://localhost/api2/ping/) = '\"pong\"'"] interval: 30s timeout: 20s retries: 3 start_period: 30s
在哪些情況下會發生這種情況?
容器退出值 2 由 Docker 保留。容器應該
exit 1
正確觸發健康檢查。該命令的退出狀態指示容器的健康狀態。可能的值是:
- 0: 成功 - 容器是健康的並且為我們準備好了
- 1:不健康 - 容器工作不正常
- 2:保留 - 不要使用此退出程式碼
來源:https ://docs.docker.com/engine/reference/builder/#healthcheck