From b7217eb599de02e5f46af8b6525429d5b4c10ca0 Mon Sep 17 00:00:00 2001 From: okxlin Date: Thu, 16 Nov 2023 16:58:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0autoheal=E5=88=B0?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/autoheal/1.2.0/.env.sample | 2 + apps/autoheal/1.2.0/data.yml | 9 +++ apps/autoheal/1.2.0/docker-compose.yml | 18 ++++++ apps/autoheal/README.md | 79 ++++++++++++++++++++++++ apps/autoheal/data.yml | 20 ++++++ apps/autoheal/latest/.env.sample | 2 + apps/autoheal/latest/data.yml | 9 +++ apps/autoheal/latest/docker-compose.yml | 18 ++++++ apps/autoheal/logo.png | Bin 0 -> 4768 bytes apps/watchtower/data.yml | 2 +- 10 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 apps/autoheal/1.2.0/.env.sample create mode 100644 apps/autoheal/1.2.0/data.yml create mode 100644 apps/autoheal/1.2.0/docker-compose.yml create mode 100644 apps/autoheal/README.md create mode 100644 apps/autoheal/data.yml create mode 100644 apps/autoheal/latest/.env.sample create mode 100644 apps/autoheal/latest/data.yml create mode 100644 apps/autoheal/latest/docker-compose.yml create mode 100644 apps/autoheal/logo.png diff --git a/apps/autoheal/1.2.0/.env.sample b/apps/autoheal/1.2.0/.env.sample new file mode 100644 index 00000000..45869dd5 --- /dev/null +++ b/apps/autoheal/1.2.0/.env.sample @@ -0,0 +1,2 @@ +CONTAINER_NAME="autoheal" +ENV1='AUTOHEAL_CONTAINER_LABEL=all' diff --git a/apps/autoheal/1.2.0/data.yml b/apps/autoheal/1.2.0/data.yml new file mode 100644 index 00000000..0b7dc1a6 --- /dev/null +++ b/apps/autoheal/1.2.0/data.yml @@ -0,0 +1,9 @@ +additionalProperties: + formFields: + - default: 'AUTOHEAL_CONTAINER_LABEL=all' + edit: true + envKey: ENV1 + labelEn: Environmental parameters + labelZh: 环境参数 + required: true + type: text diff --git a/apps/autoheal/1.2.0/docker-compose.yml b/apps/autoheal/1.2.0/docker-compose.yml new file mode 100644 index 00000000..4b63a960 --- /dev/null +++ b/apps/autoheal/1.2.0/docker-compose.yml @@ -0,0 +1,18 @@ +version: '3' +services: + autoheal: + container_name: ${CONTAINER_NAME} + restart: always + networks: + - 1panel-network + volumes: + - /var/run/docker.sock:/var/run/docker.sock + environment: + - ${ENV1} + image: willfarrell/autoheal:1.2.0 + labels: + createdBy: "Apps" + +networks: + 1panel-network: + external: true diff --git a/apps/autoheal/README.md b/apps/autoheal/README.md new file mode 100644 index 00000000..33cd3ee2 --- /dev/null +++ b/apps/autoheal/README.md @@ -0,0 +1,79 @@ +# Docker Autoheal + +Monitor and restart unhealthy docker containers. +This functionality was proposed to be included with the addition of `HEALTHCHECK`, however didn't make the cut. +This container is a stand-in till there is native support for `--exit-on-unhealthy` https://github.com/docker/docker/pull/22719. + +## Supported tags and Dockerfile links +- [`latest` (*Dockerfile*)](https://github.com/willfarrell/docker-autoheal/blob/main/Dockerfile) - Built daily +- [`1.1.0` (*Dockerfile*)](https://github.com/willfarrell/docker-autoheal/blob/1.1.0/Dockerfile) +- [`v0.7.0` (*Dockerfile*)](https://github.com/willfarrell/docker-autoheal/blob/v0.7.0/Dockerfile) + +![](https://img.shields.io/docker/pulls/willfarrell/autoheal "Total docker pulls") [![](https://images.microbadger.com/badges/image/willfarrell/autoheal.svg)](http://microbadger.com/images/willfarrell/autoheal "Docker layer breakdown") + +## How to use +### UNIX socket passthrough +```bash +docker run -d \ + --name autoheal \ + --restart=always \ + -e AUTOHEAL_CONTAINER_LABEL=all \ + -v /var/run/docker.sock:/var/run/docker.sock \ + willfarrell/autoheal +``` +### TCP socket +```bash +docker run -d \ + --name autoheal \ + --restart=always \ + -e AUTOHEAL_CONTAINER_LABEL=all \ + -e DOCKER_SOCK=tcp://HOST:PORT \ + -v /path/to/certs/:/certs/:ro \ + willfarrell/autoheal +``` +a) Apply the label `autoheal=true` to your container to have it watched. + +b) Set ENV `AUTOHEAL_CONTAINER_LABEL=all` to watch all running containers. + +c) Set ENV `AUTOHEAL_CONTAINER_LABEL` to existing label name that has the value `true`. + +Note: You must apply `HEALTHCHECK` to your docker images first. See https://docs.docker.com/engine/reference/builder/#healthcheck for details. +See https://docs.docker.com/engine/security/https/ for how to configure TCP with mTLS + +The certificates, and keys need these names: +* ca.pem +* client-cert.pem +* client-key.pem + +### Change Timezone +If you need the timezone to match the local machine, you can map the `/etc/localtime` into the container. +``` +docker run ... -v /etc/localtime:/etc/localtime:ro +``` + + +## ENV Defaults +``` +AUTOHEAL_CONTAINER_LABEL=autoheal +AUTOHEAL_INTERVAL=5 # check every 5 seconds +AUTOHEAL_START_PERIOD=0 # wait 0 seconds before first health check +AUTOHEAL_DEFAULT_STOP_TIMEOUT=10 # Docker waits max 10 seconds (the Docker default) for a container to stop before killing during restarts (container overridable via label, see below) +DOCKER_SOCK=/var/run/docker.sock # Unix socket for curl requests to Docker API +CURL_TIMEOUT=30 # --max-time seconds for curl requests to Docker API +WEBHOOK_URL="" # post message to the webhook if a container was restarted (or restart failed) +``` + +### Optional Container Labels +``` +autoheal.stop.timeout=20 # Per containers override for stop timeout seconds during restart +``` + +## Testing +```bash +docker build -t autoheal . + +docker run -d \ + -e AUTOHEAL_CONTAINER_LABEL=all \ + -v /var/run/docker.sock:/var/run/docker.sock \ + autoheal +``` \ No newline at end of file diff --git a/apps/autoheal/data.yml b/apps/autoheal/data.yml new file mode 100644 index 00000000..d68c0e14 --- /dev/null +++ b/apps/autoheal/data.yml @@ -0,0 +1,20 @@ +name: Docker Autoheal +tags: + - 工具 +title: 监视和重启不正常的 docker 容器 +type: 工具 +description: 监视和重启不正常的 docker 容器 +additionalProperties: + key: autoheal + name: Docker Autoheal + tags: + - Tool + shortDescZh: 监视和重启不正常的 docker 容器 + shortDescEn: Monitor and restart unhealthy docker containers + type: tool + crossVersionUpdate: true + limit: 1 + recommend: 0 + website: https://github.com/willfarrell/docker-autoheal + github: https://github.com/willfarrell/docker-autoheal + document: https://github.com/willfarrell/docker-autoheal diff --git a/apps/autoheal/latest/.env.sample b/apps/autoheal/latest/.env.sample new file mode 100644 index 00000000..45869dd5 --- /dev/null +++ b/apps/autoheal/latest/.env.sample @@ -0,0 +1,2 @@ +CONTAINER_NAME="autoheal" +ENV1='AUTOHEAL_CONTAINER_LABEL=all' diff --git a/apps/autoheal/latest/data.yml b/apps/autoheal/latest/data.yml new file mode 100644 index 00000000..0b7dc1a6 --- /dev/null +++ b/apps/autoheal/latest/data.yml @@ -0,0 +1,9 @@ +additionalProperties: + formFields: + - default: 'AUTOHEAL_CONTAINER_LABEL=all' + edit: true + envKey: ENV1 + labelEn: Environmental parameters + labelZh: 环境参数 + required: true + type: text diff --git a/apps/autoheal/latest/docker-compose.yml b/apps/autoheal/latest/docker-compose.yml new file mode 100644 index 00000000..8c773510 --- /dev/null +++ b/apps/autoheal/latest/docker-compose.yml @@ -0,0 +1,18 @@ +version: '3' +services: + autoheal: + container_name: ${CONTAINER_NAME} + restart: always + networks: + - 1panel-network + volumes: + - /var/run/docker.sock:/var/run/docker.sock + environment: + - ${ENV1} + image: willfarrell/autoheal:latest + labels: + createdBy: "Apps" + +networks: + 1panel-network: + external: true diff --git a/apps/autoheal/logo.png b/apps/autoheal/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..9cec3e62d1817bf3fe702d0d21ccdd15beb049a2 GIT binary patch literal 4768 zcmV;R5?}3!P)jbaz0;>2SrtTwn z)H1E<6|nIfMA{#)@DVcPBd_i=ZPq7b*aVQ=DY5Pzci0(h))HveB68OhgW4TK;2AyS zBR=37iQ5q&-xx{y0kHG{i`f8%*aIc!0CLy^Eam`g*8zFh0f5*89p?dM*a14?0yE?Q zUfBUw+5te|0Z!ZiklO)A-Ud4LYx6xd0000XbW%=J06iXX(G4#H{Qi$>R_ar^=A=Y? z`hl*|>X+iP&Xvja=Uoc^!vFvgdPzhopiyC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