This daemon monitors and restarts unhealthy docker containers instantly. This project is inspired from docker-autoheal and written on GoLang with love.
$ git clone https://github.com/maateen/dockohealer.git
$ cd dockohealer/cmd/dockohealer
$ buildTime=$(date +'%Y-%m-%d_%T')
$ gitSHA=$(git rev-parse HEAD)
$ versionString=$(git tag --sort=committerdate | tail -1)
$ go build -ldflags "-X main.buildTime=$buildTime -X main.gitSHA=$gitSHA -X main.versionString=$versionString"
$ export VERSION=v0.3
$ export OS=linux
$ export ARCH=amd64
$ wget https://github.com/maateen/dockohealer/releases/download/$VERSION/dockohealer-$OS-$ARCH-$VERSION
$ mv dockohealer-$OS-$ARCH-$VERSION /usr/local/bin/dockohealer
$ chmod +x /usr/local/bin/dockohealer
$ dockohealer -version
{"buildTime":"","gitSHA":"","level":"info","msg":"","time":"2020-06-20T19:38:43+06:00","version":""}
$ dockohealer
{"level":"info","msg":"Connected to Docker.","time":"2020-04-04T15:26:05+06:00"}
{"level":"info","msg":"Listening from Docker.","time":"2020-04-04T15:26:05+06:00"}
{"containerID":"5e37d4624fbaa128d1fbdd21e3a4cf0aa78eeff48e8902ef60eca95496d3155c","level":"info","msg":"Container is unhealthy.","time":"2020-04-04T15:26:15+06:00"}
{"containerID":"5e37d4624fbaa128d1fbdd21e3a4cf0aa78eeff48e8902ef60eca95496d3155c","level":"info","msg":"Restarting container.","time":"2020-04-04T15:26:15+06:00"}
{"containerID":"5e37d4624fbaa128d1fbdd21e3a4cf0aa78eeff48e8902ef60eca95496d3155c","level":"info","msg":"Successfully restarted container.","time":"2020-04-04T15:26:15+06:00"}
$ docker run -d \
--name dockohealer \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
maateen/dockohealer
In case of running as standalone binary, you should use systemd or supervisor to keep this daemon in running state always.
- Restart already unhealthy containers
- Add flags to the daemon
- Launch a dockerized version