github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/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**=*true|false*
    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.
    41  
    42  The latest option is not supported on the remote client.
    43  
    44  #### **--preserve-fds**=*N*
    45  
    46  Pass down to the process N additional file descriptors (in addition to 0, 1, 2).  The total FDs will be 3+N.
    47  
    48  #### **--privileged**
    49  
    50  Give extended privileges to this container. The default is *false*.
    51  
    52  By default, Podman containers are
    53  "unprivileged" and cannot, for example, modify parts of the operating system.
    54  This is because by default a container is only allowed limited access to devices.
    55  A "privileged" container is given the same access to devices as the user launching the container.
    56  
    57  A privileged container turns off the security features that isolate the
    58  container from the host. Dropped Capabilities, limited devices, read/only mount
    59  points, Apparmor/SELinux separation, and Seccomp filters are all disabled.
    60  
    61  Rootless containers cannot have more privileges than the account that launched them.
    62  
    63  
    64  #### **--tty**, **-t**
    65  
    66  Allocate a pseudo-TTY.
    67  
    68  #### **--user**, **-u**
    69  
    70  Sets the username or UID used and optionally the groupname or GID for the specified command.
    71  The following examples are all valid:
    72  --user [user | user:group | uid | uid:gid | user:gid | uid:group ]
    73  
    74  #### **--workdir**, **-w**=*path*
    75  
    76  Working directory inside the container
    77  
    78  The default working directory for running binaries within a container is the root directory (/).
    79  The image developer can set a different default with the WORKDIR instruction, which can be overridden
    80  when creating the container.
    81  
    82  ## Exit Status
    83  
    84  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
    85  non-zero code, the exit codes follow the `chroot` standard, see below:
    86  
    87    **125** The error is with Podman itself
    88  
    89      $ podman exec --foo ctrID /bin/sh; echo $?
    90      Error: unknown flag: --foo
    91      125
    92  
    93    **126** The _contained command_ cannot be invoked
    94  
    95      $ podman exec ctrID /etc; echo $?
    96      Error: container_linux.go:346: starting container process caused "exec: \"/etc\": permission denied": OCI runtime error
    97      126
    98  
    99    **127** The _contained command_ cannot be found
   100  
   101      $ podman exec ctrID foo; echo $?
   102      Error: container_linux.go:346: starting container process caused "exec: \"foo\": executable file not found in $PATH": OCI runtime error
   103      127
   104  
   105    **Exit code** The _contained command_ exit code
   106  
   107      $ podman exec ctrID /bin/sh -c 'exit 3'; echo $?
   108      3
   109  
   110  ## EXAMPLES
   111  
   112  ```
   113  $ podman exec -it ctrID ls
   114  $ podman exec -it -w /tmp myCtr pwd
   115  $ podman exec --user root ctrID ls
   116  ```
   117  
   118  ## SEE ALSO
   119  podman(1), podman-run(1)
   120  
   121  ## HISTORY
   122  December 2017, Originally compiled by Brent Baude<bbaude@redhat.com>