Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Podman Compose Systemd registers an unusable service #753

Open
tibrezus opened this issue Aug 26, 2023 · 5 comments · May be fixed by #770
Open

Podman Compose Systemd registers an unusable service #753

tibrezus opened this issue Aug 26, 2023 · 5 comments · May be fixed by #770
Labels
bug Something isn't working

Comments

@tibrezus
Copy link

While trying to run a podman-compose containing two containers of wireguard and wireguard-ui on my raspberry pi, I went into configuring the restart policy which impies:

  • Creating a unit file:
➜  wireguard-ui sudo podman-compose systemd --action create-unit
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.6.1
writing [/etc/systemd/user/podman-compose@.service]: ...
writing [/etc/systemd/user/podman-compose@.service]: done.

while in your project type `podman-compose systemd -a register`
  • Registering a service file
➜  wireguard-ui podman-compose systemd -a register
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.6.1
writing [/home/t/.config/containers/compose/projects/wireguard-ui.env]: ...
writing [/home/t/.config/containers/compose/projects/wireguard-ui.env]: done.


creating the pod without starting it: ...
.
.
.

final exit code is  0

you can use systemd commands like enable, start, stop, status, cat
all without `sudo` like this:

                systemctl --user enable --now 'podman-compose@wireguard-ui'
                systemctl --user status 'podman-compose@wireguard-ui'
                journalctl --user -xeu 'podman-compose@wireguard-ui'

and for that to work outside a session
you might need to run the following command *once*

                sudo loginctl enable-linger 'tib'

you can use podman commands like:

                podman pod ps
                podman pod stats 'pod_wireguard-ui'
                podman pod logs --tail=10 -f 'pod_wireguard-ui'

The problem is that the service will not start, neither on reboot nor manually:

wireguard-ui systemctl --user start podman-compose@wireguard-ui.service  
Job for podman-compose@wireguard-ui.service failed because the control process exited with error code.
See "systemctl --user status podman-compose@wireguard-ui.service" and "journalctl --user -xeu podman-compose@wireguard-ui.service" for details.

➜  wireguard-ui systemctl --user status 'podman-compose@wireguard-ui'
× podman-compose@wireguard-ui.service - wireguard-ui rootless pod (podman-compose)
     Loaded: loaded (/etc/xdg/systemd/user/podman-compose@.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Sat 2023-08-26 22:30:06 CEST; 7min ago
    Process: 1595 ExecStartPre=/usr/bin/podman-compose up --no-start (code=exited, status=0/SUCCESS)
    Process: 1726 ExecStartPre=/usr/bin/podman pod start pod_wireguard-ui (code=exited, status=125)
    Process: 1736 ExecStopPost=/usr/bin/podman-compose down (code=exited, status=0/SUCCESS)
        CPU: 3.845s

Aug 26 22:30:05 tib-archpi podman[1773]: 2023-08-26 22:30:05.522401386 +0200 CEST m=+0.248127112 container remove 98b41b6226f4262936359291863f4c44275de5a8273d6b37754245240e31d44e (image=docker.io/ngoduykhanh/wireguard-ui:latest, name=>
Aug 26 22:30:05 tib-archpi podman-compose[1773]: wireguard-ui
Aug 26 22:30:05 tib-archpi podman-compose[1736]: exit code: 0
Aug 26 22:30:05 tib-archpi podman-compose[1736]: podman rm wireguard
Aug 26 22:30:06 tib-archpi podman[1785]: 2023-08-26 22:30:06.239692904 +0200 CEST m=+0.691045167 container remove 519f6f6ac02efd8a0c1723890439e91a2ff1c0829b536df3337109467ff5906d (image=lscr.io/linuxserver/wireguard:latest, name=wireg>
Aug 26 22:30:06 tib-archpi podman-compose[1785]: wireguard
Aug 26 22:30:06 tib-archpi podman-compose[1736]: exit code: 0
Aug 26Warning: The unit file, source configuration file or drop-ins of podman-compose@wireguard-ui.service changed on disk. Run 'systemctl --user daemon-reload' to reload units.
 22:30:06 tib-archpi systemd[1581]: podman-compose@wireguard-ui.service: Failed with result 'exit-code'.
Aug 26 22:30:06 tib-archpi systemd[1581]: Failed to start wireguard-ui rootless pod (podman-compose).
Aug 26 22:30:06 tib-archpi systemd[1581]: podman-compose@wireguard-ui.service: Consumed 3.845s CPU time.
...skipping...
× podman-compose@wireguard-ui.service - wireguard-ui rootless pod (podman-compose)
     Loaded: loaded (/etc/xdg/systemd/user/podman-compose@.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Sat 2023-08-26 22:30:06 CEST; 7min ago
    Process: 1595 ExecStartPre=/usr/bin/podman-compose up --no-start (code=exited, status=0/SUCCESS)
    Process: 1726 ExecStartPre=/usr/bin/podman pod start pod_wireguard-ui (code=exited, status=125)
    Process: 1736 ExecStopPost=/usr/bin/podman-compose down (code=exited, status=0/SUCCESS)
        CPU: 3.845s

Aug 26 22:30:05 tib-archpi podman[1773]: 2023-08-26 22:30:05.522401386 +0200 CEST m=+0.248127112 container remove 98b41b6226f4262936359291863f4c44275de5a8273d6b37754245240e31d44e (image=docker.io/ngoduykhanh/wireguard-ui:latest, name=>
Aug 26 22:30:05 tib-archpi podman-compose[1773]: wireguard-ui
Aug 26 22:30:05 tib-archpi podman-compose[1736]: exit code: 0
Aug 26 22:30:05 tib-archpi podman-compose[1736]: podman rm wireguard
Aug 26 22:30:06 tib-archpi podman[1785]: 2023-08-26 22:30:06.239692904 +0200 CEST m=+0.691045167 container remove 519f6f6ac02efd8a0c1723890439e91a2ff1c0829b536df3337109467ff5906d (image=lscr.io/linuxserver/wireguard:latest, name=wireg>
Aug 26 22:30:06 tib-archpi podman-compose[1785]: wireguard
Aug 26 22:30:06 tib-archpi podman-compose[1736]: exit code: 0
Aug 26Warning: The unit file, source configuration file or drop-ins of podman-compose@wireguard-ui.service changed on disk. Run 'systemctl --user daemon-reload' to reload units.
 22:30:06 tib-archpi systemd[1581]: podman-compose@wireguard-ui.service: Failed with result 'exit-code'.
Aug 26 22:30:06 tib-archpi systemd[1581]: Failed to start wireguard-ui rootless pod (podman-compose).
Aug 26 22:30:06 tib-archpi systemd[1581]: podman-compose@wireguard-ui.service: Consumed 3.845s CPU time.

A more in depth log analisys shows a container with the same name is already existing, even if I did not manually started the compose file:

wireguard-ui journalctl --user -xeu podman-compose@wireguard-ui.service
Aug 26 22:52:23 tib-archpi podman-compose[3130]: podman-compose version: 1.0.6
Aug 26 22:52:23 tib-archpi podman-compose[3130]: ['podman', '--version', '']
Aug 26 22:52:23 tib-archpi podman-compose[3130]: using podman version: 4.6.1
Aug 26 22:52:23 tib-archpi podman-compose[3130]: ** excluding:  set()
Aug 26 22:52:23 tib-archpi podman-compose[3130]: ['podman', 'ps', '--filter', 'label=io.podman.compose.project=wireguard-ui', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
Aug 26 22:52:23 tib-archpi podman-compose[3130]: ['podman', 'network', 'exists', 'wireguard-ui_default']
Aug 26 22:52:23 tib-archpi podman-compose[3130]: podman create --name=wireguard --label io.podman.compose.config-hash=508772c49574768860409fbcf846579df714f7c00037e4a6f0e3640d98072dfc --label io.podman.compose.project=wireguard-ui --la>
Aug 26 22:52:23 tib-archpi podman[3157]: 2023-08-26 22:52:23.84373802 +0200 CEST m=+0.081732854 image pull 6d14a9c37b08eb96533d35645b783da669e5c0c4a98ab843e944ed94073621cf lscr.io/linuxserver/wireguard:latest
Aug 26 22:52:24 tib-archpi podman-compose[3157]: Error: creating container storage: the container name "wireguard" is already in use by 67741204d7cf2585d798c21ca939183580d895c64fefc5cebf0557e61d2be38d. You have to remove that containe>
Aug 26 22:52:24 tib-archpi podman-compose[3130]: exit code: 125
Aug 26 22:52:25 tib-archpi podman-compose[3130]: podman create --name=wireguard-ui --requires=wireguard --label io.podman.compose.config-hash=508772c49574768860409fbcf846579df714f7c00037e4a6f0e3640d98072dfc --label io.podman.compose.p>
Aug 26 22:52:25 tib-archpi podman[3166]: 2023-08-26 22:52:25.58253708 +0200 CEST m=+0.088510974 image pull 29720b04d40cb6cd64c69514d2f2aeb0b0b1c6e1ad5346133e5db5d81104dcec ngoduykhanh/wireguard-ui:latest
Aug 26 22:52:25 tib-archpi podman-compose[3166]: Error: creating container storage: the container name "wireguard-ui" is already in use by 18a5fcbeacb356262bee6759710877f438e92a43a91d3597b366fd1732747e09. You have to remove that conta>
Aug 26 22:52:25 tib-archpi podman-compose[3130]: exit code: 125
Aug 26 22:52:26 tib-archpi podman[3176]: Error: no pod with name or ID pod_wireguard-ui found: no such pod
Aug 26 22:52:26 tib-archpi systemd[1574]: podman-compose@wireguard-ui.service: Control process exited, code=exited, status=125/n/a

So I checked the linked systemd file:

# /etc/systemd/user/podman-compose@.service

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

[Service]
Type=simple
EnvironmentFile=%h/.config/containers/compose/projects/%i.env
ExecStartPre=-/usr/bin/podman-compose up --no-start    <--- conteiners created here
ExecStartPre=/usr/bin/podman pod start pod_%i                <--- Start and probaly fail here
ExecStart=/usr/bin/podman-compose wait
ExecStop=/usr/bin/podman pod stop pod_%i

[Install]
WantedBy=default.target

I see that containers are generated and started on separated instances, what I've done is creating and starting the up command:

# /etc/systemd/user/podman-compose@.service

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

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

[Install]
WantedBy=default.target

This solved my issues, still this should work out of the box.
Am I doing something wrong?
Cheers

Environment:

  • OS: Linux (Arch)
  • podman version: 4.6.1
  • podman compose version: (git hex) 1.0.6
@tibrezus tibrezus added the bug Something isn't working label Aug 26, 2023
@PointyShinyBurning
Copy link

Problem is that the systemd unit file assumes that podman-compose up defaults to creating a pod, which it possibly did on a previous version? Need to add --in-pod=1 to this line, I'll create a pull request.

@PointyShinyBurning
Copy link

Lol, please ignore the two broken pull-requests, my brain is clearly on the fritz this afternoon.

@maurerle
Copy link
Contributor

maurerle commented Oct 4, 2023

this should be fixed by merging #772

@muayyad-alsadi
Copy link
Collaborator

there is no need for #772 because in latest dev in-pod defaults to 1

actually pod-systemd was never part of previous stable, and in-pod is a breaking change that's why it's disabled in latest stable

you have two options

  • use current stable with podman per-container systemd units ( podman generate systemd CNT)
  • use latest devel branch with in-pod

@nawordar
Copy link

I just wanted to post a workaround for people using the stable version. You can create a drop-in systemd file with modified ExecStartPre commands like this:

  1. Execute systemctl --user edit podman-compose@.service
  2. Below line saying "Anything between here…" insert these lines:
    [Service]
    ExecStartPre=
    ExecStartPre=-/usr/bin/podman-compose --in-pod=1 up --no-start
    ExecStartPre=/usr/bin/podman pod start pod_%i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants