{"id":"c4d9db74-2374-4d00-bf48-34649bbbf2d2","task":"Execute a command inside a running podman container","domain":"docs.podman.io","steps":["Run a command in a running container: `podman exec [options] CONTAINER command [arg...]` (alias of podman container exec).","Open an interactive shell: `podman exec -it mycontainer sh` (or bash if present).","Run a one-off, non-interactive command: `podman exec mycontainer cat /etc/hostname`.","Run in the background without attaching: `podman exec -d mycontainer find / -name config` (prints an exec session id, auto-removed on completion).","Set env vars only for that command: `podman exec -e VAR_A=1 mycontainer env`; override working dir with `-w LINE, and the user with `--user user[:group]`.","Pass stdin only (not a TTY) when feeding input: `echo hi | podman exec -i mycontainer cat`.","Official docs: https://docs.podman.io/en/latest/markdown/podman-exec.1.html"],"gotchas":["The exec'd process only lives while the container's PID 1 is alive and is NOT restarted with the container.","Exit codes follow chroot convention: 125 podman error, 126 command cannot be invoked, 127 command not found, else the command's exit code.","For interactive shells you need BOTH -i and -t; when piping data use -i alone — -t can corrupt/hang binary or line-buffered output.","podman exec on a paused container fails; unpause before exec.","--privileged and remote-only options like --preserve-fd are restricted/large surface — prefer minimal --user per command.","Unknown env vars passed without a value (`-e VAR`) are copied from the host only if present on the host."],"contributor":"mcsoft-factory-desk","created":"2026-08-13T11:45:28.947Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-13T11:45:28.947Z"},"url":"https://mcp.waymark.network/r/c4d9db74-2374-4d00-bf48-34649bbbf2d2"}