`podman run --cap-add` ignored when `io.containers.capabilites` is set
Issue Description
I honestly do not know if podman behaves correctly, but I was slightly surprised by the behaviour and could not find what the actual correct behaviour must be.
Basically when the LABEL io.containers.capabilities is set (e.g. quay.io/podman/stable:latest), then starting the container and try to add additional capabilities with --cap-add SYS_ADMIN will be silently ignored.
Steps to reproduce the issue
Steps to reproduce the issue
podman run --rm -it --pull=always --cap-add SYS_ADMIN quay.io/podman/stable:latest capsh --print | grep sys_admin
Describe the results you received
CAP_SYS_ADMIN is not added to the running container, although it is explicitly requested via --cap-add SYS_ADMIN
Describe the results you expected
Comparing the two different results (first one seems wrong, second one correct):
$ podman run --rm -it --cap-add SYS_ADMIN quay.io/podman/stable:latest capsh --print | grep sys_admin
Current IAB: !cap_dac_read_search,!cap_linux_immutable,!cap_net_broadcast,!cap_net_admin,!cap_net_raw,!cap_ipc_lock,!cap_ipc_owner,!cap_sys_module,!cap_sys_rawio,!cap_sys_ptrace,!cap_sys_pacct,!cap_sys_admin,!cap_sys_boot,!cap_sys_nice,!cap_sys_resource,!cap_sys_time,!cap_sys_tty_config,!cap_mknod,!cap_lease,!cap_audit_write,!cap_audit_control,!cap_mac_override,!cap_mac_admin,!cap_syslog,!cap_wake_alarm,!cap_block_suspend,!cap_audit_read,!cap_perfmon,!cap_bpf,!cap_checkpoint_restore```
vs
$ podman run --rm -it --cap-add SYS_ADMIN fedora:45 capsh --print | grep sys_admin
Current: cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_sys_chroot,cap_sys_admin,cap_setfcap=ep
Bounding set =cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_sys_chroot,cap_sys_admin,cap_setfcap
podman info output
If you are unable to run podman info for any reason, please provide the podman version, operating system and its version and the architecture you are running.
:
arch: amd64
buildahVersion: 1.45.2
cdiSpecDirs:
- /etc/cdi
- /var/run/cdi
cgroupControllers:
- cpu
- memory
- pids
cgroupManager: systemd
cgroupVersion: v2
conmon:
package: app-containers/conmon-2.2.1
path: /usr/libexec/podman/conmon
version: 'conmon version 2.2.1, commit: unknown'
cpuUtilization:
idlePercent: 97.89
systemPercent: 0.55
userPercent: 1.57
cpus: 24
databaseBackend: sqlite
distribution:
distribution: '''gentoo'''
version: '''2.18'''
eventLogger: journald
freeLocks: 2048
hostname: anfink-laptop
idMappings:
gidmap:
- container_id: 0
host_id: 1000
size: 1
- container_id: 1
host_id: 1065536
size: 65536
uidmap:
- container_id: 0
host_id: 1000
size: 1
- container_id: 1
host_id: 1065536
size: 65536
kernel: 7.3.3-gentoo-dist
linkmode: dynamic
logDriver: journald
memAvailable: 49531764736
memFree: 31688851456
memTotal: 66466578432
networkBackend: netavark
networkBackendInfo:
backend: netavark
defaultNetwork: podman
dns:
package: app-containers/aardvark-dns-2.1.0
path: /usr/libexec/podman/aardvark-dns
version: aardvark-dns 2.1.0
package: app-containers/netavark-2.1.0
path: /usr/libexec/podman/netavark
version: netavark 2.1.0
ociRuntime:
name: crun
package: app-containers/crun-1.30.1
path: /usr/bin/crun
version: |-
crun version 1.30.1
commit: 079ff6a7a16d029460af882f9ea44674e6a510b6
rundir: /run/user/1000/crun
spec: 1.0.0
+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +JSON_C
os: linux
pasta:
executable: /usr/bin/pasta
package: net-misc/passt-2026.10.02
version: |
pasta 2026.10.02
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/user/1000/podman/podman.sock
rootlessNetworkCmd: pasta
rootlessPortForwarder: rootlessport
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: true
seccompEnabled: true
seccompProfilePath: /usr/share/containers/seccomp.json
selinuxEnabled: false
serviceIsRemote: false
swapFree: 0
swapTotal: 0
uptime: 145h 44m 18.00s (Approximately 6.04 days)
variant: ""
plugins:
authorization: null
log:
- k8s-file
- none
- passthrough
- journald
network:
- bridge
- macvlan
- ipvlan
volume:
- local
registries:
search:
- ghcr.io
- docker.io
store:
containerStore:
number: 0
paused: 0
running: 0
stopped: 0
graphDriverName: overlay
graphOptions: {}
graphRoot: /home/anfink/.local/share/containers/storage
graphRootAllocated: 904063750144
graphRootUsed: 373644615680
graphStatus:
Backing Filesystem: extfs
Native Overlay Diff: "true"
Supports d_type: "true"
Supports shifting: "false"
Supports volatile: "true"
Using metacopy: "false"
imageCopyTmpDir: /var/tmp
imageStore:
number: 7
runRoot: /run/user/1000/containers
transientStore: false
volumePath: /home/anfink/.local/share/containers/storage/volumes
version:
APIVersion: 6.1.4
BuildOrigin: Gentoo Portage
Built: 1792531601
BuiltTime: Tue Oct 20 23:26:41 2026
GitCommit: ""
GoVersion: go1.27.3-X:nodwarf5
Os: linux
OsArch: linux/amd64
Version: 6.1.4
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
Yes
Additional environment details
Additional environment details
Additional information
Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting
I suppose it technically works as documented:
Users can set a special LABEL io.containers.capabilities=CAP1,CAP2,CAP3 in a Containerfile that specifies the list of Linux capabilities required for the container to run properly. This label specified in a container image tells Podman to run the container with just these capabilities. Podman launches the container with just the specified capabilities, as long as this list of capabilities is a subset of the default list.
The way --cap-add is currently used in this case to extend the base set only in case the image asks for more than the regular default caps allow.
We can certainly debate if this makes sense or not, if a users asks for more they should be able to set this IMO. Its not clear to me if the behaviour was actually intentional, the original commit/PR does not mention it explicitly https://github.com/podman-container-tools/podman/pull/5206
I'd love to work on this if the desired behavior is clear. should an explicit request by the person running the container override the image restriction?