github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/docs/source/markdown/podman-exec.1.md (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 will run in the background and the exec session will be automatically removed when it completes. The **podman exec** command will print the ID of the exec session and exit immediately after it starts. 19 20 #### **--detach-keys**=*sequence* 21 22 Specify the key sequence for detaching a container. Format is a single character `[a-Z]` or one or more `ctrl-<value>` characters where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. Specifying "" will disable this feature. The default is *ctrl-p,ctrl-q*. 23 24 #### **--env**, **-e** 25 26 You may specify arbitrary environment variables that are available for the 27 command to be executed. 28 29 #### **--env-file**=*file* 30 31 Read in a line delimited file of environment variables. 32 33 #### **--interactive**, **-i** 34 35 When set to true, keep stdin open even if not attached. The default is *false*. 36 37 #### **--latest**, **-l** 38 39 Instead of providing the container name or ID, use the last created container. If you use methods other than Podman 40 to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines) 41 42 #### **--preserve-fds**=*N* 43 44 Pass down to the process N additional file descriptors (in addition to 0, 1, 2). The total FDs will be 3+N. 45 46 #### **--privileged** 47 48 Give extended privileges to this container. The default is *false*. 49 50 By default, Podman containers are 51 "unprivileged" and cannot, for example, modify parts of the operating system. 52 This is because by default a container is only allowed limited access to devices. 53 A "privileged" container is given the same access to devices as the user launching the container. 54 55 A privileged container turns off the security features that isolate the 56 container from the host. Dropped Capabilities, limited devices, read/only mount 57 points, Apparmor/SELinux separation, and Seccomp filters are all disabled. 58 59 Rootless containers cannot have more privileges than the account that launched them. 60 61 62 #### **--tty**, **-t** 63 64 Allocate a pseudo-TTY. 65 66 #### **--user**, **-u** 67 68 Sets the username or UID used and optionally the groupname or GID for the specified command. 69 The following examples are all valid: 70 --user [user | user:group | uid | uid:gid | user:gid | uid:group ] 71 72 #### **--workdir**, **-w**=*path* 73 74 Working directory inside the container 75 76 The default working directory for running binaries within a container is the root directory (/). 77 The image developer can set a different default with the WORKDIR instruction, which can be overridden 78 when creating the container. 79 80 ## Exit Status 81 82 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 83 non-zero code, the exit codes follow the `chroot` standard, see below: 84 85 **125** The error is with Podman itself 86 87 $ podman exec --foo ctrID /bin/sh; echo $? 88 Error: unknown flag: --foo 89 125 90 91 **126** The _contained command_ cannot be invoked 92 93 $ podman exec ctrID /etc; echo $? 94 Error: container_linux.go:346: starting container process caused "exec: \"/etc\": permission denied": OCI runtime error 95 126 96 97 **127** The _contained command_ cannot be found 98 99 $ podman exec ctrID foo; echo $? 100 Error: container_linux.go:346: starting container process caused "exec: \"foo\": executable file not found in $PATH": OCI runtime error 101 127 102 103 **Exit code** The _contained command_ exit code 104 105 $ podman exec ctrID /bin/sh -c 'exit 3'; echo $? 106 3 107 108 ## EXAMPLES 109 110 ``` 111 $ podman exec -it ctrID ls 112 $ podman exec -it -w /tmp myCtr pwd 113 $ podman exec --user root ctrID ls 114 ``` 115 116 ## SEE ALSO 117 **[podman(1)](podman.1.md)**, **[podman-run(1)](podman-run.1.md)** 118 119 ## HISTORY 120 December 2017, Originally compiled by Brent Baude<bbaude@redhat.com>