{"id":27010456,"url":"https://github.com/zwsq/chealth","last_synced_at":"2025-10-10T14:04:22.069Z","repository":{"id":185318736,"uuid":"673323767","full_name":"zwsq/CHealth","owner":"zwsq","description":"Docker Container Health Check Script is a bash script that monitors the health status of Docker containers and automatically restarts them if they are unhealthy. This script runs in the background as a systemd service and logs its activities to journalctl.","archived":false,"fork":false,"pushed_at":"2023-08-06T10:26:33.000Z","size":19,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-27T05:23:13.431Z","etag":null,"topics":["docker","docker-compose","health-check","inspector"],"latest_commit_sha":null,"homepage":"","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/zwsq.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,"zenodo":null}},"created_at":"2023-08-01T11:24:24.000Z","updated_at":"2025-07-16T02:36:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"db10a24d-e3ee-41a4-b3b6-f5650beb904f","html_url":"https://github.com/zwsq/CHealth","commit_stats":null,"previous_names":["zwsq/chealth"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zwsq/CHealth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zwsq%2FCHealth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zwsq%2FCHealth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zwsq%2FCHealth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zwsq%2FCHealth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zwsq","download_url":"https://codeload.github.com/zwsq/CHealth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zwsq%2FCHealth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279004184,"owners_count":26083688,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["docker","docker-compose","health-check","inspector"],"created_at":"2025-04-04T11:05:11.183Z","updated_at":"2025-10-10T14:04:22.064Z","avatar_url":"https://github.com/zwsq.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Docker Image Build and Push](https://github.com/zwsq/CHealth/actions/workflows/docker-image.yml/badge.svg)](https://github.com/zwsq/CHealth/actions/workflows/docker-image.yml)\n# Docker Automatic Restart Unhealthy Container Script\n\nThe Docker Container Health Check Script is a bash script that monitors the health status of Docker containers and automatically restarts them if they are unhealthy. This script runs in the background as a systemd service and logs its activities to journalctl.\n\n## Requirements\n\n- Linux-based operating system\n- Docker installed and configured\n\n## Installation\n  \n### I) Using Docker\n1. You need to create a chealth.conf file and put the desired container names in each line of the file.\n2. Now you can use following docker run command to start the healthchecker container. Remember to replace the /etc/chealth.conf with your chealth.conf file address on your machine in docker run command.\n```bash\ndocker run -d --name=CHealth -v /etc/chealth.conf:/usr/local/bin/chealth.conf -v /var/run/docker.sock:/var/run/docker.sock:ro zwsq/chealth:14\n```\n#### Note: Since the container need to know the status of the host containers, acess to the docker.sock file of the host is required.\n### II) Using bash and systemd\n1. Clone the repository to your desired location:\n\n```bash\ngit clone https://github.com/zwsq/CHealth.git\n```\n2. Go to the downloaded directory:\n\n```bash\ncd CHealth\n```\n3. Make the script executable:\n```bash\nsudo chmod +x chealth.sh\n```\n4. Add the names of the Docker containers you want to monitor, one per line in the chealth.conf file.\n```\ncontainer1\ncontainer2\ncontainer3\n```\n5. Open the chealth.service file in an editor and modify `ExecStart` and `WorkingDirectory` according to the location of chealth.sh file on your machine.\n```bash\nsudo nano chealth.service\n```\n\n```\nWorkingDirectory=/path/to/chealth/directory\nExecStart=/path/to/chealth/directory/chealth.sh\n```\n6. Copy `chealth.service` file you `/etc/systemd/system` and reload systemd daemon.\n```bash\nsudo cp chealth.sh /etc/systemd/system \u0026\u0026 sudo systemctl daemon-reload\n```\n7. Now you can enable and start the service.\n```bash\nsudo systemctl enable --now chealth.service\n```\n\n## Customization\nChanging the Check Interval: If you want to modify the check interval, you can edit the sleep duration in the script. For example, to check every 60 seconds, change sleep 30 to sleep 60.\n\nAdding/Removing Containers: To add or remove containers to be monitored, simply edit the containers.txt file, adding or removing container names as needed. The script will automatically pick up the changes during its next iteration.\n\n## Contributing\nContributions are welcome! If you find any issues or have suggestions for improvements, please create an issue or submit a pull request.\n\n## License\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzwsq%2Fchealth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzwsq%2Fchealth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzwsq%2Fchealth/lists"}