{"id":19485120,"url":"https://github.com/piero24/dockerrestartscript","last_synced_at":"2026-04-30T12:32:25.084Z","repository":{"id":251511168,"uuid":"837628632","full_name":"Piero24/DockerRestartScript","owner":"Piero24","description":"Simple script for containers that do not restart properly","archived":false,"fork":false,"pushed_at":"2024-08-03T14:59:55.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-13T23:06:23.284Z","etag":null,"topics":["big-bear-casaos","casaos","casaos-appstore","docker","docker-compose","homeserver","openvpn","openvpn-monitor","openvpn-server","restart","restart-container","server"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Piero24.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-08-03T14:36:14.000Z","updated_at":"2024-08-03T15:09:18.000Z","dependencies_parsed_at":"2024-08-03T16:14:52.375Z","dependency_job_id":null,"html_url":"https://github.com/Piero24/DockerRestartScript","commit_stats":null,"previous_names":["piero24/dockerrestartscript"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Piero24/DockerRestartScript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piero24%2FDockerRestartScript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piero24%2FDockerRestartScript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piero24%2FDockerRestartScript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piero24%2FDockerRestartScript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Piero24","download_url":"https://codeload.github.com/Piero24/DockerRestartScript/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piero24%2FDockerRestartScript/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32465009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"online","status_checked_at":"2026-04-30T02:00:05.929Z","response_time":57,"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":["big-bear-casaos","casaos","casaos-appstore","docker","docker-compose","homeserver","openvpn","openvpn-monitor","openvpn-server","restart","restart-container","server"],"created_at":"2024-11-10T20:25:55.878Z","updated_at":"2026-04-30T12:32:25.066Z","avatar_url":"https://github.com/Piero24.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DockerRestartScript\n\nThis is a simple script for people who have had problems with Docker container auto-restart after a reboot or an incorrect shutdown. In my case, the problem is with the [OpenVPN Access Server](https://openvpn.net) Docker container.\nSpecifically, these applications are run on Docker containers managed by [CasaOS](https://www.casaos.io).\n\n## Problem Definition\nAfter a restart caused by a power outage or other issues, all containers would function and start automatically except for the OpenVPN container.\nNot finding an optimal solution, I decided to create a script that stops the failed auto-restart attempt of the container and starts a new, functioning one.\n\n## Basic Info\nThe script waits for the operating system and Docker containers to load. Then it checks if the OpenVPN container is loaded correctly. If it is not, the script stops the current container and starts a new one.\nThe script is modifiable and adaptable to other containers that may have similar issues. Simply change the name of the container you want to monitor.\n\n## Prepare the Script\nModify the script as follows:\n- Change **CONTAINER_NAME** to the name of the container you want to monitor.\n- \n## Start the Script at Boot\nTo start the script at system startup, a couple of steps are enough.\n\n- Save the script to an appropriate location on your system, such as `/usr/local/bin/check_and_restart_container.sh`, and make it executable with the command sudo `chmod +x /usr/local/bin/check_and_restart_container.sh`\n- Create a service file called mounter.service in /etc/systemd/system/: `sudo nano /etc/systemd/system/check_and_restart_container.service`\n- Inside this file, insert the following content:\n\n```ini\n[Unit]\nDescription=Check and Restart Docker Container if Restarting\nAfter=network.target docker.service\nRequires=docker.service\n\n[Service]\nType=oneshot\nExecStart=/usr/local/bin/check_and_restart_container.sh\nRemainAfterExit=true\n\n[Install]\nWantedBy=multi-user.target\n```\n\n- restart the deamon `sudo systemctl daemon-reload`\n- enable the service to start during boot: `sudo systemctl enable /etc/systemd/system/check_and_restart_container.service`\n\nNow, when the system starts, the script checks if the container is running properly.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiero24%2Fdockerrestartscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiero24%2Fdockerrestartscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiero24%2Fdockerrestartscript/lists"}