docker-versatile-postfix icon indicating copy to clipboard operation
docker-versatile-postfix copied to clipboard

Is there a way to create health check in docker compose?

Open gromspys opened this issue 1 year ago • 2 comments

I use docker compose to run image and I can't find a way to create health check. For example, when I use redis I can create healthcheck like:

version: '3.8'
services:
  redis:
    restart: always
    image: redis:6.2-alpine
....
  healthcheck:
    test: ["CMD", "redis-cli", "ping"]
    interval: 1s
    timeout: 3s
    retries: 10
....

Is there some command that can be used for healthcheck to restart container if something wrong inside?

gromspys avatar Jan 24 '24 14:01 gromspys

you can use ps aux and grep for postfix dkim etc.

those are the services you should need to check

service rsyslog start
if [ -z ${DISABLE_DKIM+x} ]
then
  service opendkim start
fi
service saslauthd start
service postfix start

MarvAmBass avatar Jan 25 '24 05:01 MarvAmBass

Not sure that it's what I mean. Sometimes I see that container is up and all processes are running, but I can't connect to the container from another container (with java client) to send emails. And I have to restart container manually. Instead of that I would like to call some command every 5 seconds to check everything working in container.

gromspys avatar Jan 27 '24 11:01 gromspys