ikke-t / podman-container-systemd

creates systemd files and creates containers using podman
118 stars 44 forks source link

fix: remove container before starting #43

Closed yajo closed 3 years ago

yajo commented 3 years ago

After running the role to start a service, I get these logs in loop:

Aug 08 07:09:57 rpi4test systemd[1]: Starting mando-traefik Podman Container...
Aug 08 07:09:57 rpi4test systemd[1]: Started mando-traefik Podman Container.
Aug 08 07:09:57 rpi4test podman[16458]: Error: error creating container storage: the container name "mando-traefik" is already in use by "cf78da2cb108e5c0389bd7a99f8d27fe9dd94284a14e33ead5481b2ef3683c7b". You have to remove that container to be able
 to reuse that name.: that name is already in use
Aug 08 07:09:57 rpi4test systemd[1]: mando-traefik.service: Main process exited, code=exited, status=125/n/a
Aug 08 07:09:57 rpi4test systemd[1]: mando-traefik.service: Failed with result 'exit-code'.
Aug 08 07:10:27 rpi4test systemd[1]: mando-traefik.service: Scheduled restart job, restart counter is at 2.
Aug 08 07:10:27 rpi4test systemd[1]: Stopped mando-traefik Podman Container.

This fixes the problem by always making sure the container is removed before start.

ikke-t commented 3 years ago

Hmmm, there was a reason why I left it out originally. I had it there at the begiinng. Perhaps it was there due that I already had manually set the same containers, and didn't want to kill them if they already existed. But that's likely useless nowadays, so I agree this is a good change. thanks

yajo commented 3 years ago

I suppose the rm -f would not need the separate stop thingie, but I assume it's there due the graceful shut down time?

Yes, so the app has time to process the TERM signal from the stop command for some seconds before being killed.