Skip to content

Instantly share code, notes, and snippets.

@SanariSan
Created September 29, 2022 20:40
Show Gist options
  • Save SanariSan/c74b84f1a35a5a4918eab0c59c0673f1 to your computer and use it in GitHub Desktop.
Save SanariSan/c74b84f1a35a5a4918eab0c59c0673f1 to your computer and use it in GitHub Desktop.
Restart docker after Let's encrypt update

.path unit that watches the certificate, which then starts a corresponding oneshot .service with multiple ExecStart lines


.path unit:

[Unit]
Description=Triggers restart of docker containers when Lets Encrypt certificate is updated

[Path]
PathChanged=/etc/letsencrypt/archive/foobar.example.com/

[Install]
WantedBy=multi-user.target
WantedBy=system-update.target

.service unit:

[Unit]
Description=Restart containers using foobar.example.com certificate

[Service]
Type=oneshot
ExecStart=docker restart foobar
ExecStart=docker restart barbaz
ExecStart=docker restart foobaz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment