You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a) Apply the label `autoheal=true` to your container to have it watched.
35
-
36
-
b) Set ENV `AUTOHEAL_CONTAINER_LABEL=all` to watch all running containers.
37
-
38
-
c) Set ENV `AUTOHEAL_CONTAINER_LABEL` to existing label name that has the value `true`.
39
-
40
-
Note: You must apply `HEALTHCHECK` to your docker images first. See https://docs.docker.com/engine/reference/builder/#healthcheck for details.
41
-
See https://docs.docker.com/engine/security/https/ for how to configure TCP with mTLS
42
-
43
-
The certificates, and keys need these names:
37
+
#### TCP with mTLS (HTTPS)
38
+
```bash
39
+
docker run -d \
40
+
--name autoheal \
41
+
--restart=always \
42
+
--tlscacert=/certs/ca.pem \
43
+
--tlscert=/certs/client-cert.pem \
44
+
--tlskey=/certs/client-key.pem \
45
+
-e AUTOHEAL_CONTAINER_LABEL=all \
46
+
-e DOCKER_HOST=tcp://$HOST:2376 \
47
+
-e DOCKER_SOCK=tcps://$HOST:2376 \
48
+
-e DOCKER_TLS_VERIFY=1 \
49
+
-v /path/to/certs/:/certs/:ro \
50
+
willfarrell/autoheal
51
+
```
52
+
The certificates and keys need these names and resides under /certs inside the container:
44
53
* ca.pem
45
54
* client-cert.pem
46
55
* client-key.pem
47
56
57
+
> See https://docs.docker.com/engine/security/https/ for how to configure TCP with mTLS
58
+
48
59
### Change Timezone
49
60
If you need the timezone to match the local machine, you can map the `/etc/localtime` into the container.
50
-
```
61
+
```bash
51
62
docker run ... -v /etc/localtime:/etc/localtime:ro
52
63
```
53
64
65
+
### 2. Use in your container image
66
+
Choose one of the three alternatives:
54
67
55
-
## ENV Defaults
56
-
```
57
-
AUTOHEAL_CONTAINER_LABEL=autoheal
58
-
AUTOHEAL_INTERVAL=5 # check every 5 seconds
59
-
AUTOHEAL_START_PERIOD=0 # wait 0 seconds before first health check
60
-
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)
61
-
DOCKER_SOCK=/var/run/docker.sock # Unix socket for curl requests to Docker API
62
-
CURL_TIMEOUT=30 # --max-time seconds for curl requests to Docker API
63
-
WEBHOOK_URL="" # post message to the webhook if a container was restarted (or restart failed)
64
-
```
68
+
a) Apply the label `autoheal=true` to your container to have it watched;<br/>
69
+
b) Set ENV `AUTOHEAL_CONTAINER_LABEL=all` to watch all running containers;<br/>
70
+
c) Set ENV `AUTOHEAL_CONTAINER_LABEL` to existing container label that has the value `true`;<br/>
65
71
66
-
### Optional Container Labels
67
-
```
68
-
autoheal.stop.timeout=20 # Per containers override for stop timeout seconds during restart
72
+
> Note: You must apply `HEALTHCHECK` to your docker images first.<br/>
73
+
> See https://docs.docker.com/engine/reference/builder/#healthcheck for details.
74
+
75
+
#### Docker Compose (example)
76
+
```yaml
77
+
services:
78
+
app:
79
+
extends:
80
+
file: ${PWD}/services.yml
81
+
service: app
82
+
labels:
83
+
autoheal-app: true
84
+
85
+
autoheal:
86
+
deploy:
87
+
replicas: 1
88
+
environment:
89
+
AUTOHEAL_CONTAINER_LABEL: autoheal-app
90
+
image: willfarrell/autoheal:latest
91
+
network_mode: none
92
+
restart: always
93
+
volumes:
94
+
- /etc/localtime:/etc/localtime:ro
95
+
- /var/run/docker.sock:/var/run/docker.sock
69
96
```
70
97
71
-
## Testing
98
+
#### Optional Container Labels
99
+
|`autoheal.stop.timeout=20` |Per containers override for stop timeout seconds during restart|
100
+
| --- | --- |
101
+
102
+
## Environment Defaults
103
+
|Variable |Description|
104
+
| --- | --- |
105
+
|`AUTOHEAL_CONTAINER_LABEL=autoheal` |set to existing label name that has the value `true`|
106
+
|`AUTOHEAL_INTERVAL=5` |check every 5 seconds|
107
+
|`AUTOHEAL_START_PERIOD=0` |wait 0 seconds before first health check|
108
+
|`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)|
109
+
|`AUTOHEAL_ONLY_MONITOR_RUNNING=false` |All containers monitored by default. Set this to true to only monitor running containers. This will result in Paused contaners being ignored.|
110
+
|`DOCKER_SOCK=/var/run/docker.sock` |Unix socket for curl requests to Docker API|
111
+
|`CURL_TIMEOUT=30` |--max-time seconds for curl requests to Docker API|
112
+
|`WEBHOOK_URL=""` |post message to the webhook if a container was restarted (or restart failed)|
0 commit comments