How to fix Raspberry Pi Docker Swarm Certificate

If your Raspberry Pi hasn't been turned on for a long time (it was off for an extended period), its certificate might expire.

This instruction should be performed on the main node. An example of an error that can be seen with the command `sudo journalctl -u docker -r`:

msg=“swarm component could not be started” error="error while loading TLS certificate in
/var/lib/docker/swarm/certificates/swarm-node.crt: certificate

First, get a list of all recent system boots:

journalctl --list-boots

For example, the last boot of your Pi was `2022-10-04 19:20:00`. You need to run the script and advance the date by 2 months each time until you reach the current date.

For example:

sudo ./time-fix.sh set-date '2022-10-05 00:00:00'
sudo ./time-fix.sh set-date '2023-01-01 00:00:00'
sudo ./time-fix.sh set-date '2023-02-01 00:00:00'
sudo ./time-fix.sh set-date '2023-04-01 00:00:00'
sudo ./time-fix.sh set-date '2023-06-01 00:00:00'
sudo ./time-fix.sh set-date '2023-08-01 00:00:00'
sudo ./time-fix.sh restore
./cloud_os.sh compose
sudo reboot

To view certificate information and its expiration date, run the command:

sudo openssl x509 -in /var/lib/docker/swarm/certificates/swarm-node.crt -text -noout

Then, this file needs to be copied to other nodes, and they should be restarted.

Publish date: 21 Feb 2026