Pruning doesn't stop oneshot quadlet units
Issue Description
Pruning (podman system prune, podman network prune, etc.) deletes the resources (network, etc.) without stopping the relevant quadlet systemd units. Subsequently, systemd will believe that resource is still active and proceed to dependents, which will fail as the dependency isn't really active.
A typical setup is a scheduled oneshot container with it's own network, combined with a scheduled pruning job. Pruning will delete the network while leaving the network quadlet unit active (because it's a Type=oneshot + RemainAfterExit=yes). On the next scheduled start, systemd will believe the network is still active and start the container right away, while the container will fail as the network doesn't actually exist.
A workaround is to make the dependency resource to have StopWhenUnneeded=yes under [Unit], if all dependencies are managed by systemd.
Steps to reproduce the issue
- Configure with quadlet a oneshot container and its own network with
Network=foo.network. systemctl start <container-unit>- At this point, container unit is dead while the network unit remains active.
podman network prunesystemctl start <container-unit>
Describe the results you received
- After
podman network prune, the network is deleted while the network unit remains active. - After
systemctl start <container-unit>, container startup fails due to missing network.
Describe the results you expected
- After
podman network prune, the network is deleted and the network unit becomes dead. - After
systemctl start <container-unit>, container starts successfully.
Alternatively, there should be a separate quadlet-aware mechanism to prune resources.
podman info output
host:
arch: amd64
buildahVersion: 1.43.1
cgroupControllers:
- cpuset
- cpu
- io
- memory
- hugetlb
- pids
- rdma
- misc
- dmem
cgroupManager: systemd
cgroupVersion: v2
conmon:
package: Unknown
path: /nix/store/qjr9z558rr3a2px5mhl8hcy6iic94bq7-podman-helper-binary-wrapper/bin/conmon
version: 'conmon version 2.2.1, commit: c8cc2c4db27531bd4e084ce7857f73cd21ee639d'
cpuUtilization:
idlePercent: 85.97
systemPercent: 9.26
userPercent: 4.77
cpus: 4
databaseBackend: sqlite
distribution:
codename: yarara
distribution: nixos
version: "26.05"
eventLogger: journald
freeLocks: 2031
hostname: furnace
idMappings:
gidmap: null
uidmap: null
kernel: 6.18.33
linkmode: dynamic
logDriver: journald
memFree: 2454179840
memTotal: 16669544448
networkBackend: netavark
networkBackendInfo:
backend: netavark
defaultNetwork: podman
dns:
package: Unknown
path: /nix/store/36aysi4cxfcixrh6wd0pr44nbk0siksj-podman-5.8.2/libexec/podman/aardvark-dns
version: aardvark-dns 1.17.1
package: Unknown
path: /nix/store/36aysi4cxfcixrh6wd0pr44nbk0siksj-podman-5.8.2/libexec/podman/netavark
version: netavark 1.17.2
ociRuntime:
name: crun
package: Unknown
path: /nix/store/qjr9z558rr3a2px5mhl8hcy6iic94bq7-podman-helper-binary-wrapper/bin/crun
version: |-
crun version 1.27.1
commit: 3ec076b3b6714ec2f1a10533cf18d5605a6de637
rundir: /run/crun
spec: 1.0.0
+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +YAJL
os: linux
pasta:
executable: /nix/store/36aysi4cxfcixrh6wd0pr44nbk0siksj-podman-5.8.2/libexec/podman/pasta
package: Unknown
version: |
pasta 2025_09_19.623dbf6
Copyright Red Hat
GNU General Public License, version 2 or later
<https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
remoteSocket:
exists: true
path: /run/podman/podman.sock
rootlessNetworkCmd: pasta
security:
apparmorEnabled: false
capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
rootless: false
seccompEnabled: true
seccompProfilePath: ""
selinuxEnabled: false
serviceIsRemote: false
slirp4netns:
executable: ""
package: ""
version: ""
swapFree: 0
swapTotal: 0
uptime: 1459h 34m 23.00s (Approximately 60.79 days)
variant: ""
plugins:
authorization: null
log:
- k8s-file
- none
- passthrough
- journald
network:
- bridge
- macvlan
- ipvlan
volume:
- local
registries:
search:
- docker.io
- quay.io
store:
configFile: /etc/containers/storage.conf
containerStore:
number: 17
paused: 0
running: 17
stopped: 0
graphDriverName: overlay
graphOptions: {}
graphRoot: /var/lib/containers/storage
graphRootAllocated: 974374170624
graphRootUsed: 188119638016
graphStatus:
Backing Filesystem: extfs
Native Overlay Diff: "true"
Supports d_type: "true"
Supports shifting: "true"
Supports volatile: "true"
Using metacopy: "false"
imageCopyTmpDir: /var/tmp
imageStore:
number: 17
runRoot: /run/containers/storage
transientStore: false
volumePath: /var/lib/containers/storage/volumes
version:
APIVersion: 5.8.2
Built: 315532800
BuiltTime: Tue Jan 1 00:00:00 1980
GitCommit: ""
GoVersion: go1.26.5
Os: linux
OsArch: linux/amd64
Version: 5.8.2Podman in a container
No
Privileged Or Rootless
Privileged
Upstream Latest Release
Yes
Additional environment details
No response
Additional information
No response
Source: podman-container-tools/podman