github.com/containers/podman/v5@v5.1.0-rc1/docs/source/markdown/podman-exec.1.md.in (about) 1 % podman-exec 1 2 3 ## NAME 4 podman\-exec - Execute a command in a running container 5 6 ## SYNOPSIS 7 **podman exec** [*options*] *container* [*command* [*arg* ...]] 8 9 **podman container exec** [*options*] *container* [*command* [*arg* ...]] 10 11 ## DESCRIPTION 12 **podman exec** executes a command in a running container. 13 14 ## OPTIONS 15 16 #### **--detach**, **-d** 17 18 Start the exec session, but do not attach to it. The command runs in the background, and the exec session is automatically removed when it completes. The **podman exec** command prints the ID of the exec session and exits immediately after it starts. 19 20 @@option detach-keys 21 22 @@option env 23 24 @@option env-file 25 26 @@option interactive 27 28 @@option latest 29 30 @@option preserve-fd 31 32 @@option preserve-fds 33 34 @@option privileged 35 36 @@option tty 37 38 @@option user 39 40 @@option workdir 41 42 ## Exit Status 43 44 The exit code from `podman exec` gives information about why the command within the container failed to run or why it exited. When `podman exec` exits with a 45 non-zero code, the exit codes follow the `chroot` standard, see below: 46 47 **125** The error is with Podman itself 48 49 $ podman exec --foo ctrID /bin/sh; echo $? 50 Error: unknown flag: --foo 51 125 52 53 **126** The _contained command_ cannot be invoked 54 55 $ podman exec ctrID /etc; echo $? 56 Error: container_linux.go:346: starting container process caused "exec: \"/etc\": permission denied": OCI runtime error 57 126 58 59 **127** The _contained command_ cannot be found 60 61 $ podman exec ctrID foo; echo $? 62 Error: container_linux.go:346: starting container process caused "exec: \"foo\": executable file not found in $PATH": OCI runtime error 63 127 64 65 **Exit code** The _contained command_ exit code 66 67 $ podman exec ctrID /bin/sh -c 'exit 3'; echo $? 68 3 69 70 ## EXAMPLES 71 72 Execute command in selected container with a stdin and a tty allocated: 73 ``` 74 $ podman exec -it ctrID ls 75 ``` 76 77 Execute command with the overridden working directory in selected container with a stdin and a tty allocated: 78 ``` 79 $ podman exec -it -w /tmp myCtr pwd 80 ``` 81 82 Execute command as the specified user in selected container: 83 ``` 84 $ podman exec --user root ctrID ls 85 ``` 86 87 ## SEE ALSO 88 **[podman(1)](podman.1.md)**, **[podman-run(1)](podman-run.1.md)** 89 90 ## HISTORY 91 December 2017, Originally compiled by Brent Baude<bbaude@redhat.com>