It seems that anytime I log into my homeserver, podman containers are restarting:
❯ ssh podman@192.168.1.116
podman@192.168.1.116's password:
Web console: https://homeserver.localdomain:9090/ or https://192.168.1.116:9090/
Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last login: Wed Nov 22 21:38:24 2023 from ::ffff:192.168.1.111
[podman@homeserver ~]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a4b5a1ca375 docker.io/louislam/uptime-kuma:latest node server/serve... 2 seconds ago Up 3 seconds (starting) 0.0.0.0:3001->3001/tcp uptime-kuma
3b97cda03874 lscr.io/linuxserver/unifi-network-application:latest 2 seconds ago Up 2 seconds (starting) 0.0.0.0:8080->8080/tcp, 0.0.0.0:8443->8443/tcp, 0.0.0.0:8843->8843/tcp, 0.0.0.0:8880->8880/tcp, 0.0.0.0:3478->3478/udp, 0.0.0.0:10001->10001/udp systemd-unifi_network_application
a6b35bd7ccd7 docker.io/pihole/pihole:latest 2 seconds ago Up 3 seconds (starting) 0.0.0.0:53->53/udp, 0.0.0.0:53->53/tcp, 0.0.0.0:80->80/tcp systemd-pihole
e45ca3fde4bf docker.io/library/mongo:4.4.25 mongod 2 seconds ago Up 2 seconds (starting) 0.0.0.0:27017->27017/tcp unifi_mongodb
The same happened yesterday at about 17:15 when I logged in via cockpit: all containers were created and restarted immediately after my login.
I'm using quadlet files to create systemd services and this is an example file:
[Unit]
Description=UniFi MongoDB
After=local-fs.target
[Container]
Image=docker.io/mongo:4.4.25
ContainerName=unifi_mongodb
Environment=MONGO_INITDB_ROOT_USERNAME=root
Secret=unifi_mongodb_root_password,type=env,target=MONGO_INITDB_ROOT_PASSWORD
Network=unifi_network_application.network
Volume=unifi_mongodb_data:/data/db
PublishPort=27017:27017
HealthCmd=CMD-SHELL mongo --eval 'db.runCommand({ping:1})'
HealthInterval=30s
HealthRetries=2
HealthOnFailure=kill
[Service]
Restart=on-failure
[Install]
WantedBy=multi-user.target default.target
I'm not sure if the latter is misconfigured or I'm missing something else.
Your containers don't restart, they just start at login time, because they stop when you log out. (Looking at system logs with journalctl -b
will probably reveal this.)
You're using quadlet to generate user services, not system services (hence systemctl --user
), and those are managed by a "user service manager" instance that automatically starts on user login and stops on logout.
Use loginctl enable-linger $USER
to have your user service manager start on boot and remain running until system shutdown.