podman-compose
podman-compose copied to clipboard
Containers created by podman-compose can't be started with systemd
Hello.
The method podman has to generate systemd service files doesn't work with containers created by podman-compose. Here's a sample service file created by the command podman generate systemd FOLDER_NAME_SERVICE_NAME_1 > FOLDER_NAME_SERVICE_NAME_1.service:
Jan 02 12:02:41 localhost.localdomain systemd[1]: Stopped Podman container-985441b9fbf8757c5d00699d3ed638324074ee4d7be4e8639c88274a300a01de.service.
░░ Subject: A stop job for unit FOLDER_NAME_SERVICE_NAME_1.service has finished
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A stop job for unit FOLDER_NAME_SERVICE_NAME_1.service has finished.
░░
░░ The job identifier is 3860 and the job result is done.
Jan 02 12:02:41 localhost.localdomain audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=FOLDER_NAME_SERVICE_NAME_1 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=>
Jan 02 12:02:41 localhost.localdomain systemd[1]: FOLDER_NAME_SERVICE_NAME_1.service: Start request repeated too quickly.
Jan 02 12:02:41 localhost.localdomain audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=FOLDER_NAME_SERVICE_NAME_1 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=?>
Jan 02 12:02:41 localhost.localdomain systemd[1]: FOLDER_NAME_SERVICE_NAME_1.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ The unit FOLDER_NAME_SERVICE_NAME_1.service has entered the 'failed' state with result 'exit-code'.
Jan 02 12:02:41 localhost.localdomain systemd[1]: Failed to start Podman container-985441b9fbf8757c5d00699d3ed638324074ee4d7be4e8639c88274a300a01de.service.
░░ Subject: A start job for unit FOLDER_NAME_SERVICE_NAME_1.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit FOLDER_NAME_SERVICE_NAME_1.service has finished with a failure.
░░
░░ The job identifier is 3860 and the job result is failed.
I have the same issue and can't find a way to avoid it. Manually changing the created service file and adding timeouts and restart restrictions, does not solve the issue. It already fails with just one try. For me it looks like, systemd does record the intermediate exit-codes and immediately stops/restarts the whole service.
systemctl status container-mqtt.service
● container-mqtt.service - Podman container-mqtt.service
Loaded: loaded (/etc/systemd/system/container-mqtt.service; enabled; preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2023-12-14 10:49:06 UTC; 60ms ago
Docs: man:podman-generate-systemd(1)
Process: 2820 ExecStartPre=/bin/rm -f /run/container-mqtt.service.ctr-id (code=exited, status=0/SUCCESS)
Process: 2821 ExecStart=/usr/bin/podman run --cidfile=/run/container-mqtt.service.ctr-id --cgroups=no-conmon --rm --sdnotify=conmon --replace --name=mqtt -d --label io.podman.compose.config-hash=8f2962091d7
d302f641b0d8beac276a90b078eac84103a006b5ecae866dc73e8 --label io.podman.compose.project=user --label io.podman.compose.version=1.0.6 --label [email protected] --label com.docker.co
mpose.project=user --label com.docker.compose.project.working_dir=/home/user --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.c
ompose.service=mqtt -v /home/user/eclipse-mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf -v /home/user/eclipse-mosquitto/mosquitto.log:/mosquitto/log/mosquitto.log -v /home/user/eclipse-mosquitto/dat
a:/mosquitto/data --net user_default --network-alias mqtt -p 1883:1883 -p 9001:9001 docker.io/eclipse-mosquitto:2.0.18 mosquitto -c /mosquitto/config/mosquitto.conf (code=exited, status=125)
Process: 2831 ExecStopPost=/usr/bin/podman rm -f --ignore -t 10 --cidfile=/run/container-mqtt.service.ctr-id (code=exited, status=125)
Main PID: 2821 (code=exited, status=125)
CPU: 263ms