1podman-exec(1)() podman-exec(1)()
2
3
4
6 podman-exec - Execute a command in a running container
7
8
10 podman exec [options] container [command [arg ...]]
11
12
13 podman container exec [options] container [command [arg ...]]
14
15
17 podman exec executes a command in a running container.
18
19
21 --detach, -d
22 Start the exec session, but do not attach to it. The command will run
23 in the background and the exec session will be automatically removed
24 when it completes. The podman exec command will print the ID of the
25 exec session and exit immediately after it starts.
26
27
28 --detach-keys=sequence
29 Specify the key sequence for detaching a container. Format is a single
30 character [a-Z] or one or more ctrl-<value> characters where <value> is
31 one of: a-z, @, ^, [, , or _. Specifying "" will disable this feature.
32 The default is ctrl-p,ctrl-q.
33
34
35 --env, -e
36 You may specify arbitrary environment variables that are available for
37 the command to be executed.
38
39
40 --env-file=file
41 Read in a line delimited file of environment variables.
42
43
44 --interactive, -i
45 When set to true, keep stdin open even if not attached. The default is
46 false.
47
48
49 --latest, -l
50 Instead of providing the container name or ID, use the last created
51 container. If you use methods other than Podman to run containers such
52 as CRI-O, the last started container could be from either of those
53 methods. (This option is not available with the remote Podman client,
54 including Mac and Windows (excluding WSL2) machines)
55
56
57 --preserve-fds=N
58 Pass down to the process N additional file descriptors (in addition to
59 0, 1, 2). The total FDs will be 3+N.
60
61
62 --privileged
63 Give extended privileges to this container. The default is false.
64
65
66 By default, Podman containers are "unprivileged" and cannot, for exam‐
67 ple, modify parts of the operating system. This is because by default
68 a container is only allowed limited access to devices. A "privileged"
69 container is given the same access to devices as the user launching the
70 container.
71
72
73 A privileged container turns off the security features that isolate the
74 container from the host. Dropped Capabilities, limited devices,
75 read/only mount points, Apparmor/SELinux separation, and Seccomp fil‐
76 ters are all disabled.
77
78
79 Rootless containers cannot have more privileges than the account that
80 launched them.
81
82
83 --tty, -t
84 Allocate a pseudo-TTY.
85
86
87 --user, -u
88 Sets the username or UID used and optionally the groupname or GID for
89 the specified command. The following examples are all valid: --user
90 [user | user:group | uid | uid:gid | user:gid | uid:group ]
91
92
93 --workdir, -w=path
94 Working directory inside the container
95
96
97 The default working directory for running binaries within a container
98 is the root directory (/). The image developer can set a different de‐
99 fault with the WORKDIR instruction, which can be overridden when creat‐
100 ing the container.
101
102
104 The exit code from podman exec gives information about why the command
105 within the container failed to run or why it exited. When podman exec
106 exits with a non-zero code, the exit codes follow the chroot standard,
107 see below:
108
109
110 125 The error is with Podman itself
111
112
113 $ podman exec --foo ctrID /bin/sh; echo $?
114 Error: unknown flag: --foo
115 125
116
117
118
119 126 The contained command cannot be invoked
120
121
122 $ podman exec ctrID /etc; echo $?
123 Error: container_linux.go:346: starting container process caused "exec: \"/etc\": permission denied": OCI runtime error
124 126
125
126
127
128 127 The contained command cannot be found
129
130
131 $ podman exec ctrID foo; echo $?
132 Error: container_linux.go:346: starting container process caused "exec: \"foo\": executable file not found in $PATH": OCI runtime error
133 127
134
135
136
137 Exit code The contained command exit code
138
139
140 $ podman exec ctrID /bin/sh -c 'exit 3'; echo $?
141 3
142
143
144
146 $ podman exec -it ctrID ls
147 $ podman exec -it -w /tmp myCtr pwd
148 $ podman exec --user root ctrID ls
149
150
151
153 podman(1), podman-run(1)
154
155
157 December 2017, Originally compiled by Brent Baudebbaude@redhat.com
158 ⟨mailto:bbaude@redhat.com⟩
159
160
161
162 podman-exec(1)()