Last week, I wrote about How to restart a single container with docker-compose. The approach is manual, hence will be repetitive and error-prone. And since we want to automate almost everything as a DevOps egineer, today I’ll show you a better way of handling unhealthy containers.
- Docker Compose
A few days ago, I found this popular Docker image with around 107 millions docker pulls, so I thought to myself, this must be it. Lightweight, simple, straight-to-the-point solution.
from the CLI
docker run -d \ --name autoheal \ --restart=always \ -e AUTOHEAL_CONTAINER_LABEL=all \ -v /var/run/docker.sock:/var/run/docker.sock \ willfarrell/autoheal
version: "3.7" services: autoheal: restart: on-failure image: willfarrell/autoheal volumes: - /var/run/docker.sock:/var/run/docker.sock environment: - "AUTOHEAL_CONTAINER_LABEL=all" ...
Give it a spin and let me know what you think. You could even add a Slack or MS Teams integration, by passing a webhook URL to the
WEBHOOK_URL environment variable.
Official GitHub repo: https://github.com/willfarrell/docker-autoheal
Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.