runc-exec(8)
π runc-exec(8) β the "hey bestie, let's pop a new process inside ur container" page π
okay so real talk: this is the runc-exec page from the System Manager's Manual, and it's genuinely one of the most useful little commands in the whole runc-verse. no cap. it lets you yeet a brand new process into a container that's already up and running. like sliding into someone's DMs but it's a namespace. π«Ά
β¨ NAME β¨
runc-exec β execute new process inside the container π¦
β¨ SYNOPSIS β¨
runc exec [option ...] container-id [--] command [arg ...]
runc exec [option ...] -p process.json container-id
so basically there's two whole moods here: either you hand it a command and args directly (and yeah, that -- is there in case ur command has flags that look like runc flags β use it, bestie, it's your friend π
), or you hand it a process.json with -p and let the file do the talking. pick ur fighter. π₯
β¨ OPTIONS β¨
--console-socketpath β the path to anAF_UNIXsocket that's gonna receive a file descriptor pointing at the master end of the console's pseudoterminal. there's a whole doc for this, go look:docs/terminalsβ¨https://github.com/opencontainers/runc/blob/master/docs/terminals.mdβ©. π--cwdpath β change to path inside the container before running the command. it's giving "cd first, then slay". πββοΈ--env,-ename=value β set an environment variable name to value. can be specified multiple times, so stack 'em up like ur fave skincare routine. πΈ--tty,-tβ allocate a pseudo-TTY. yes, so it feels like a real terminal. iconic behavior. π--user,-uuid[:gid] β run the command as a user specified by uid, and optionally a group specified by gid. pick ur identity bestie, main character energy. π--additional-gids,-ggid β add additional group IDs. can be specified multiple times. the more the merrier, fr fr. π--process,-pprocess.json β instead of typing out every single exec parameter on the command line, just pull them from a process.json, a JSON file holding the process specification as defined by the OCI runtime spec β¨https://github.com/opencontainers/runtime-spec/blob/master/config.md#processβ©. lowkey the laziest and most powerful option here. π--detach,-dβ detach from the container's process. like leaving the group chat on read, but for processes. π--pid-filepath β specify the file to write the container process' PID to. π--process-labellabel β set the asm process label for the process, which is commonly used withselinux(7). π--apparmorprofile β set theapparmor(7)profile for the process. π‘οΈ--no-new-privsβ set the "no new privileges" value for the process. π«--capcap β add a capability to the bounding set for the process. can be specified multiple times. collect them like stickers. β--preserve-fdsN β pass N additional file descriptors into the container (so that's stdio +$LISTEN_FDS+ N in total). default is0. π§--ignore-pausedβ allow exec in a paused container. by default, if a container is paused,runc execerrors out β this option overrides that. heads up though: a paused container needs to be resumed for the exec to actually complete. so like, this is not a magic unlock, it's a permission slip. π«--cgrouppath | controller[,controller...]:path β execute a process in a sub-cgroup. if the cgroup you specified doesn't exist, you get an error back, no vibes, no mercy. default is an empty path, which means use the container's top level cgroup.- for cgroup v1 only, you can specify a particular controller (or multiple comma-separated controllers), and you can use the option multiple times to set different paths for different controllers.
- note for cgroup v2: in case the process can't join the top level cgroup, the
runc execfallback is to try joining the cgroup of the container's init. this fallback can be disabled by using--cgroup /. π
β¨ EXIT STATUS β¨
exits with a status of command (unless -d is used, in which case nah), or 255 if an error occurred. so 255 is the "something went wrong bestie" number. π
β¨ EXAMPLES β¨
if the container can run the ps(1) command, the following will output a list of processes running in the container:
# runc exec <container-id> ps
look at that. one line. whole process list. ate. π₯
β¨ SEE ALSO β¨
runc(8). that's the whole family, go say hi. π
mwah π this has been runc-exec(8) from the System Manager's Manual β same page name on both ends, cute lil bookends, periodt. now go exec something iconic bestie β¨π
π¦ where this page comes from
- alpine 3.24: runc-doc 1.4.3-r2 Β· Apache-2.0
- arch rolling: runc 1.5.2-1 Β· Apache
- fedora 43: runc 2:1.3.1-1.fc43 Β· Apache-2.0 and BSD-2-Clause and BSD-3-Clause and MIT
- fedora 43: runc 2:1.5.2-3.fc43 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND MIT AND MPL-2.0
- fedora 44: runc 2:1.4.1-1.fc44 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND MIT AND MPL-2.0
- fedora 44: runc 2:1.5.2-3.fc44 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND MIT AND MPL-2.0
- nixpkgs unstable: runc 1.5.2
- ubuntu resolute: runc 1.4.0-0ubuntu1 Β· Apache-2.0
- ubuntu resolute: runc-stable 1.3.4-0ubuntu1 Β· Apache-2.0
- ubuntu stonking: runc 1.5.1-0ubuntu2 Β· Apache-2.0
- ubuntu stonking: runc-stable 1.5.1-0ubuntu2 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms