adding health check to docker container adding health check to docker container docker docker

adding health check to docker container


I gave up on using the HEALTHCHECK command in Dockerfile and instead I am changing the nginx.conf file by adding

    location /health {        access_log off;        return 200 "healthy\n";    }

docker-compose.yml remains the same.This works well enough for me.


As a solution, you can use the following example -How to Add a Health Check to Your Docker Container

There's a minor correction to the Dockerfile they provide though as there's an issue to check the health status (curl had to be installed there as well but let me know if you need any help or have any question).

Please refer to this particular one as a solution -

FROM python:3.6-alpineCOPY . /appWORKDIR /appRUN pip install -r requirements.txtRUN mkdir /data \    && apk add --no-cache \        openssl \        curl \        dumb-init \        postgresql-libs \        ca-certificates#CMD apt-get install curlHEALTHCHECK CMD curl -f http://localhost:5000/ || exit 1CMD ["python", "app.py"]