Docker container health check command (1.12) (not in Docker file!)

Docker version 1.12, I got Dockerfilefrom here

FROM nginx:latest

RUN touch /marker

ADD ./check_running.sh /check_running.sh
RUN chmod +x /check_running.sh

HEALTHCHECK --interval=5s --timeout=3s CMD ./check_running.sh

I can check for updates and health checks using a check_running.shshell script. Here the check_running.shscript is copied to image, so there is a container in this running container.

Now, my question is whether there is a way to test the health of the container and the script, also located outside.

I, with the exception of the health check command, in order to get the performance of the container (depending on what we wrote in the script), IF the container does not work well, it should roll back to the previous version (the kind of process that controls the containers, if it's not good, it should back to previous)

thank

+4
5

- script .

, , ,

:

  • , docker exec. . , - cat script.sh | docker exec -it container sh -s.
  • , . , ( ps -Zax ), --user 12345, , , . , . /var/lib/docker/devicemapper/mnt/<hash>/rootfs.
  • HEALTHCHECK docker inspect --format='{{json .State.Health.Status}}' <containername> , , Docker: HEALTHCHECK CMD wget -q -s http://google.com, , .

3, .

+3

. Docker HealthCheck. " " docker "" dockerfile. ! , , . !

+2

Dockerfile HEALTHCHECK, . , , , .

, , .

0

, docker inspect .

, , , /healthz, , , .

0

Docker ,

docker inspect --format='{{json .State.Health}}' your-container-name
0

Source: https://habr.com/ru/post/1650620/


All Articles