Skip to content

Conversation

@MayorFaj
Copy link
Contributor

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

Add resource limit options (--cpus, --memory, --cpu-shares, --cpuset-cpus, --cpuset-mems, --memory-swap) to podman exec command. Requires OCI runtime support (crun >= 1.9 or runc >= 1.2).

Changes

  • Added CLI flags: --cpus, --memory, --cpu-shares, --cpuset-cpus, --cpuset-mems, --memory-swap
  • Implemented resource limit parsing and cgroup creation for exec sessions
  • Added integration and system tests with runtime support detection
  • Updated man page documentation

Requirements

  • Requires OCI runtime support: crun >= 1.9 or runc >= 1.2
  • Resource limits create a temporary sub-cgroup for the exec session

Testing

podman run -d --name test alpine top
podman exec --cpus=0.5 --memory=256m test stress-ng --vm 1 --vm-bytes 200M

fixes #26875

@packit-as-a-service
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@giuseppe
Copy link
Member

How is it supposed to work on cgroup v2?

There can't be processes in a parent cgroup, so you'll first need to move all the processes to a sub-cgroup.

$ podman exec -d ctrID find /path/to/search -name yourfile
```

Execute command with resource limits (requires crun >= 1.9 or runc >= 1.2):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the OCI runtimes do not have any support for exec and cgroups limits, so this is wrong

@MayorFaj MayorFaj changed the title add resource limit options to podman exec command [WIP] add resource limit options to podman exec command Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add CPU and Memory Limits to podman exec

2 participants