Reputation: 530
I am starting and stopping container using systemd unit file service as.
Taking container name as hello
podman ps
shows hello
in output
podman generate systemd --new --files --name hello
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run --cidfile=%t/%n.ctr-id --sdnotify=conmon --cgroups=no-conmon -d --hostname=first containerID
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
When I reboot system and check
systemctl status container-hello
I get status as Active: running
But if I run podman ps -a
, I get to see hello
as inactive
as well as another container added say hello2
as running
.
hello2
is associated with the unit file created in step 1 and hello
is not.
I have used --hostname as suggested but I cannot see container with that name when checked with podman ps pr podman ps -a
Upvotes: 0
Views: 611
Reputation: 530
What worked for me:
--name
parameter in the ExecStart
label inside unit file as:ExecStart=/usr/bin/podman run --cidfile=%t/%n.ctr-id --sdnotify=conmon --cgroups=no-conmon -d --name=container_name ID
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
I erased this line from the unit file.
Results:
Upvotes: 0
Reputation: 9412
From https://docs.podman.io/en/latest/markdown/podman-run.1.html: Podman generates a UUID for each container, and if a name is not assigned to the container with --name then it will generate a random string name. The name is useful any place you need to identify a container. This works for both background and foreground containers.
So you may want to edit your unit file to contain
ExecStart=/usr/bin/podman run ... --name hello
If that fixes the problem but the way you generate the unit should cover the name, maybe it is worth filing a bug for podman.
Upvotes: 1