The SWAG docker container from linuxserver.io is a great plug-and-play solution for serving websites and self-hosted docker based applications. For me it's been taking care of SSL certificate renewal and has been serving several docker based applications including Nextcloud, Vaultwarden, Jellyfin and Syncthing.
SWAG stops working at night
Recently after an upgrade to 2.4.0, I noticed all my applications were down the next morning. I logged into the server and restarted the SWAG container happily seeing that it fixed the issue.
The happiness did not last however; the day after in the morning my phone reported yet again that it's not able to synchronize my appointments. Sure enough SWAG stopped working again. To my surprise there was nothing in the logs
docker logs swag and the container was up and running.
My websites became unavailable around 2am - around this time SWAG's certbot appears to renew SSL certificates for all domains. I jumped into the container
docker exec -it swag /bin/bash and manually started the process
certbot renew -v. Sure enough the process errored out with
Failed to renew certificate xxx.xx with error: Some challenges have failed.
Apparently my domains failed the DNS record challange and rightfully so: They were test domains I moved to a different DNS without updating my SWAG configuration.
Removing these domains from SWAG's docker-compose.yml and running
docker-compose up -d fixed the problem permanently.
SWAG nowadays seems to die after not being able to renew SSL certificates at night. If you find it stops serving your sites, log into the container and run certbot manually with the verbose flag
certbot renew -v. This might shed some light on a configuration problem responsible for the downtime.
While not being able to renew SSL certificates should not be the reason to stop working altogether and should be fixed in SWAG soon, in the meantime I happily wake up to a working server.