为什么我无法启用使用 podmangenerate 创建的 systemd 服务?

为什么我无法启用使用 podmangenerate 创建的 systemd 服务?

鉴于此设置:

---
version "3"
services:
  wireguard:
    image: "lscr.io/linuxserver/wireguard"
    container_name: "wireguard"
    cap_add:
      - "NET_ADMIN"
    environment:
      PUID: "1000"
      PGID: "1000"
      TZ: "Europe/London"
    ports:
      - "8080:8080"
      - "6881:6881"
      - "6881:6881/udp"
    volumes:
      - "./wireguard/config:/config"
      - "/lib/modules:/lib/modules"
    sysctls:
      - "net.ipv4.conf.all.src_valid_mark=1"
    privileged: true
  qbittorrent:
    image: "lscr.io/linuxserver/qbittorrent"
    container_name: "qbittorrent"
    network_mode: "service:wireguard"
    environment:
      PUID: "1000"
      PGID: "1000"
      TZ: "Europe/London"
      WEBUI_PORT: "8080"
    volumes:
      - "./qbittorrent/config:/config"
      - "./qbittorrent/downloads:/downloads"

为什么我无法启动和/或启用各自的 systemd 服务?这些是我运行过的命令:

sudo loginctl enable-linger myuser

podman-compose up -d

podman stop -a

podman generate systemd --new --files --name wireguard
podman generate systemd --new --files --name qbittorrent

podman system prune # pressed 'y'

mkdir -p $HOME/.config/systemd/user

sudo mv -v container-wireguard.service /etc/systemd/system/
mv -v container-qbittorrent.service $HOME/.config/systemd/user/

sudo systemctl daemon-reload
systemctl --user daemon-reload

sudo systemctl start container-wireguard.service
systemctl --user start container-qbittorrent.service

的结果cat container-wireguard.service

# container-wireguard.service
# autogenerated by Podman 4.3.1
# Thu Sep 14 14:07:16 CEST 2023

[Unit]
Description=Podman container-wireguard.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=%t/containers

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm \
    -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run \
    --cidfile=%t/%n.ctr-id \
    --cgroups=no-conmon \
    --rm \
    --sdnotify=conmon \
    --replace \
    --name=wireguard \
    -d \
    --label io.podman.compose.config-hash=f7ac51a86e7d72fe8967478b47a2cd9a2e53d672610c3caa797afe25d62e2dfd \
    --label io.podman.compose.project=torrent \
    --label io.podman.compose.version=1.0.6 \
    --label [email protected] \
    --label com.docker.compose.project=torrent \
    --label com.docker.compose.project.working_dir=/home/myuser/podman/torrent \
    --label com.docker.compose.project.config_files=docker-compose.yml \
    --label com.docker.compose.container-number=1 \
    --label com.docker.compose.service=wireguard \
    --cap-add NET_ADMIN \
    -e PUID=1000 \
    -e PGID=1000 \
    -e TZ=Europe/London \
    -e ALLOWEDIPS=0.0.0.0/0 \
    -e LOG_CONFS=True \
    -v /home/myuser/podman/torrent/wireguard/config:/config:z \
    -v /lib/modules:/lib/modules:z \
    --net torrent_default \
    --network-alias wireguard \
    -p 8080:8080 \
    -p 6881:6881 \
    -p 6881:6881/udp \
    --sysctl net.ipv4.conf.all.src_valid_mark=1 \
    --privileged linuxserver/wireguard:latest
ExecStop=/usr/bin/podman stop \
    --ignore -t 10 \
    --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm \
    -f \
    --ignore -t 10 \
    --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all

[Install]
WantedBy=default.target

的结果sudo systemctl status container-wireguard.service

× container-wireguard.service - Podman container-wireguard.service
     Loaded: loaded (/etc/systemd/system/container-wireguard.service; disabled; preset: enabled)
     Active: failed (Result: exit-code) since Thu 2023-09-14 14:18:06 CEST; 26min ago
       Docs: man:podman-generate-systemd(1)
   Main PID: 4500 (code=exited, status=125)
        CPU: 52ms

Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Scheduled restart job, restart counter is at 5.
Sep 14 14:18:06 homeserver systemd[1]: Stopped container-wireguard.service - Podman container-wireguard.service.
Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Start request repeated too quickly.
Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Failed with result 'exit-code'.
Sep 14 14:18:06 homeserver systemd[1]: Failed to start container-wireguard.service - Podman container-wireguard.service.

结果journalctl -xeu container-wireguard.service

Sep 14 14:18:05 homeserver systemd[1]: Failed to start container-wireguard.service - Podman container-wireguard.service.
░░ Subject: A start job for unit container-wireguard.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit container-wireguard.service has finished with a failure.
░░ 
░░ The job identifier is 873 and the job result is failed.
Sep 14 14:18:05 homeserver systemd[1]: container-wireguard.service: Scheduled restart job, restart counter is at 3.
░░ Subject: Automatic restarting of a unit has been scheduled
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ Automatic restarting of the unit container-wireguard.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
Sep 14 14:18:05 homeserver systemd[1]: Stopped container-wireguard.service - Podman container-wireguard.service.
░░ Subject: A stop job for unit container-wireguard.service has finished
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A stop job for unit container-wireguard.service has finished.
░░ 
░░ The job identifier is 987 and the job result is done.
Sep 14 14:18:05 homeserver systemd[1]: Starting container-wireguard.service - Podman container-wireguard.service...
░░ Subject: A start job for unit container-wireguard.service has begun execution
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit container-wireguard.service has begun execution.
░░ 
░░ The job identifier is 987.
Sep 14 14:18:05 homeserver podman[4458]: Error: unable to find network with name or ID torrent_default: network not found
Sep 14 14:18:05 homeserver systemd[1]: container-wireguard.service: Main process exited, code=exited, status=125/n/a
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ An ExecStart= process belonging to unit container-wireguard.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 125.
Sep 14 14:18:06 homeserver podman[4476]: Error: reading CIDFile: open /run/container-wireguard.service.ctr-id: no such file or directory
Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Control process exited, code=exited, status=125/n/a
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ An ExecStopPost= process belonging to unit container-wireguard.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 125.
Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit container-wireguard.service has entered the 'failed' state with result 'exit-code'.
Sep 14 14:18:06 homeserver systemd[1]: Failed to start container-wireguard.service - Podman container-wireguard.service.
░░ Subject: A start job for unit container-wireguard.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit container-wireguard.service has finished with a failure.
░░ 
░░ The job identifier is 987 and the job result is failed.
Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Scheduled restart job, restart counter is at 4.
░░ Subject: Automatic restarting of a unit has been scheduled
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ Automatic restarting of the unit container-wireguard.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
Sep 14 14:18:06 homeserver systemd[1]: Stopped container-wireguard.service - Podman container-wireguard.service.
░░ Subject: A stop job for unit container-wireguard.service has finished
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A stop job for unit container-wireguard.service has finished.
░░ 
░░ The job identifier is 1101 and the job result is done.
Sep 14 14:18:06 homeserver systemd[1]: Starting container-wireguard.service - Podman container-wireguard.service...
░░ Subject: A start job for unit container-wireguard.service has begun execution
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit container-wireguard.service has begun execution.
░░ 
░░ The job identifier is 1101.
Sep 14 14:18:06 homeserver podman[4500]: Error: unable to find network with name or ID torrent_default: network not found
Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Main process exited, code=exited, status=125/n/a
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ An ExecStart= process belonging to unit container-wireguard.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 125.
Sep 14 14:18:06 homeserver podman[4519]: Error: reading CIDFile: open /run/container-wireguard.service.ctr-id: no such file or directory
Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Control process exited, code=exited, status=125/n/a
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ An ExecStopPost= process belonging to unit container-wireguard.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 125.
Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit container-wireguard.service has entered the 'failed' state with result 'exit-code'.
Sep 14 14:18:06 homeserver systemd[1]: Failed to start container-wireguard.service - Podman container-wireguard.service.
░░ Subject: A start job for unit container-wireguard.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit container-wireguard.service has finished with a failure.
░░ 
░░ The job identifier is 1101 and the job result is failed.
Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Scheduled restart job, restart counter is at 5.
░░ Subject: Automatic restarting of a unit has been scheduled
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ Automatic restarting of the unit container-wireguard.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
Sep 14 14:18:06 homeserver systemd[1]: Stopped container-wireguard.service - Podman container-wireguard.service.
░░ Subject: A stop job for unit container-wireguard.service has finished
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A stop job for unit container-wireguard.service has finished.
░░ 
░░ The job identifier is 1215 and the job result is done.
Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Start request repeated too quickly.
Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit container-wireguard.service has entered the 'failed' state with result 'exit-code'.
Sep 14 14:18:06 homeserver systemd[1]: Failed to start container-wireguard.service - Podman container-wireguard.service.
░░ Subject: A start job for unit container-wireguard.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit container-wireguard.service has finished with a failure.
░░ 
░░ The job identifier is 1215 and the job result is failed.

的结果podman ps -a

CONTAINER ID  IMAGE                                     COMMAND     CREATED         STATUS      PORTS                                                                                                     NAMES
00b4f3b11446  docker.io/linuxserver/wireguard:latest                40 minutes ago  Created     0.0.0.0:8080->8080/tcp, 0.0.0.0:6881->6881/tcp, 0.0.0.0:8083-8084->3000-3001/tcp, 0.0.0.0:6881->6881/udp  wireguard
12d5c92f0c1e  docker.io/linuxserver/qbittorrent:latest              40 minutes ago  Created     0.0.0.0:8080->8080/tcp, 0.0.0.0:6881->6881/tcp, 0.0.0.0:8083-8084->3000-3001/tcp, 0.0.0.0:6881->6881/udp  qbittorrent

的结果podman network ls

...
a11919c606c3  torrent_default  bridge

任何帮助是极大的赞赏。

相关内容