{"id":23381258,"url":"https://github.com/bvis/swarm-healthcheck-test","last_synced_at":"2025-04-08T08:26:53.920Z","repository":{"id":149012821,"uuid":"68028703","full_name":"bvis/swarm-healthcheck-test","owner":"bvis","description":"Just for simplify the testing of a service that takes more than N seconds to be running","archived":false,"fork":false,"pushed_at":"2016-09-13T18:37:12.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T05:29:51.004Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bvis.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-12T16:52:11.000Z","updated_at":"2016-09-12T17:03:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"5cfc2152-d74a-49a1-8e42-29c5184407f6","html_url":"https://github.com/bvis/swarm-healthcheck-test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvis%2Fswarm-healthcheck-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvis%2Fswarm-healthcheck-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvis%2Fswarm-healthcheck-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvis%2Fswarm-healthcheck-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bvis","download_url":"https://codeload.github.com/bvis/swarm-healthcheck-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247803203,"owners_count":20998722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-21T20:48:37.090Z","updated_at":"2025-04-08T08:26:53.903Z","avatar_url":"https://github.com/bvis.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swarm-healthcheck-test\n\nI'm trying to launch a service based on Mysql and it initially takes more than 25 seconds to be ready, as it initialises databases structures or starts to replicate from a master.\n\nTo be sure that the tasks are not added to the IPVS until it is ready to serve consistent data I've added a HEALTHCHECK command to the image to be sure about it.\n\nWhen I launch it as a container (docker run ...) I see it works perfectly. But when I launch it as a service (docker service create...) it seems that is docker who's killing the service at 25th second after launch the task.\n\n## How to reproduce\n\nI've created a simple image for doing it. As docker hub still does not support HEALTHCHECK command I'm providing this repo.\n\n```\ngit clone git@github.com:bvis/swarm-healthcheck-test.git\ncd swarm-healthcheck-test\ndocker build -t swarm-healthcheck-test .\ndocker run -d --name test swarm-healthcheck-test\nwatch -n 1 \"docker ps | grep swarm-healthcheck\" \n```\n\nYou'll see the watch with the output:\n\n```\n3689d7faaead  swarm-healthcheck-test  \"/bin/sh -c /start.sh\"   11 seconds ago      Up 11 seconds (health: starting) test\n...\nce7f471f224b  swarm-healthcheck-test  \"/bin/sh -c /start.sh\"   16 seconds ago      Up 15 seconds (unhealthy)        test\n...\nce7f471f224b  swarm-healthcheck-test  \"/bin/sh -c /start.sh\"   30 seconds ago      Up 29 seconds (unhealthy)        test\n...\nce7f471f224b  swarm-healthcheck-test  \"/bin/sh -c /start.sh\"   About a minute ago  Up About a minute (healthy)      test\n```\n\nIt works as expected!\n\nBut when you launch it as a service:\n\n```\ndocker service create --name test swarm-healthcheck-test\ncjqegebcn1g44qtvjrs8ujiq5\nwatch -n 1 \"docker service ps test\"\nID                         NAME    IMAGE              NODE             DESIRED STATE  CURRENT STATE             ERROR\n7qljdhtxfc4744zfbczrkwwuj  test.1  swarm-healthcheck  swarm-cluster-1  Running        Starting 1 seconds ago\n...\nID                         NAME    IMAGE              NODE             DESIRED STATE  CURRENT STATE             ERROR\n7qljdhtxfc4744zfbczrkwwuj  test.1  swarm-healthcheck  swarm-cluster-1  Running        Starting 19 seconds ago\n...\nID                         NAME        IMAGE              NODE             DESIRED STATE  CURRENT STATE         ERROR\n5inlhe2qrwcryn3dioz4mixpe  test.1      swarm-healthcheck  swarm-cluster-1  Ready          Ready 1 seconds ago\n89wriwa3a7zomv0tybd9tkr9v   \\_ test.1  swarm-healthcheck  swarm-cluster-1  Shutdown       Failed 3 seconds ago  \"task: non-zero exit (137): do\"\n```\n\nAnd I've seen that it always happens on 25th second.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbvis%2Fswarm-healthcheck-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbvis%2Fswarm-healthcheck-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbvis%2Fswarm-healthcheck-test/lists"}