containers / containers/podman-compose

podman-compode systemd unit and ExecStop

Open
#580 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
6.2k
Forks
622
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
Now when I create systemd unit I get file:

```ini
[Unit]
Description=%i rootless pod (podman-compose)

[Service]
Type=simple
EnvironmentFile=%h/.config/containers/compose/projects/%i.env
ExecStartPre=-/usr/local/bin/podman-compose up --no-start
ExecStartPre=/usr/bin/podman pod start pod_%i
ExecStart=/usr/local/bin/podman-compose wait
ExecStop=/usr/bin/podman pod stop pod_%i

[Install]
WantedBy=default.target
```
The ExecStop command stops all containers that belong to pod but doesn't delete them. Sometimes when I update images with `podman auto-update` or `podman pull` and `systemctl restart --user podman-compose@pod_name` they are not fully updated. I have to stop and delete pod containers using `podman-compose -f podman-compose-file.yml down` and then start using `systemctl start --user podman-compose@pod_name`

I tried to change ExecStop string to this one:
```ini
ExecStop=-/usr/local/bin/podman-compose down
```

But it's not good when I get errors in one of the containers after starting: instead of stopping container with errors all pod's containers were deleted, `podman ps -a` didn't show anything and I couldn't get log using `podman logs container_name` command.

**Describe the solution you'd like**
Ability to create systemd unit which not only stops all pod's containers but also deletes them. And when errors occurs in one of containers don't remove all containers for pod, only stop container with errors.

**Describe alternatives you've considered**
Now I have to stop and delete containers manually with `podman-compose -f podman-compose-file.yml down`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.