|Andrey Arapov 34390002c6||1 year ago|
|Dockerfile||1 year ago|
|README.md||1 year ago|
|entrypoint.sh||1 year ago|
This example shows how health check works in Docker Swarm.
Container runs a nginx server and it also runs a script which writes a
/usr/share/nginx/html/status file on every odd run which is then
picked by the health check that expects
alive status from the nginx running
in the container.
So every odd run the container gets
Then you can observe that running this container in Docker Engine alone will
not restart it. Hence we will run it as a service in the Docker Swarm which
will ensure the container gets restarted until it gets
docker build -t healthcheck-test .
Make sure you have recent Docker Engine installed.
docker swarm init
docker service create \ --name test1 \ --mount type=bind,src=/tmp,dst=/usr/share/nginx/html \ --detach healtcheck-test
docker ps |grep test1 docker service ls
docker service rm test1 docker swarm leave --force rm -rf -- /tmp/html
If you want to restart the container manually, you need to downscale it to 0 first and then upscale it back again.
docker service scale test1=0 docker service scale test1=1