github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/man/docker-exec.1.md (about) 1 % DOCKER(1) Docker User Manuals 2 % Docker Community 3 % JUNE 2014 4 # NAME 5 docker-exec - Run a command in a running container 6 7 # SYNOPSIS 8 **docker exec** 9 [**-d**|**--detach**] 10 [**--detach-keys**[=*[]*]] 11 [**-e**|**--env**[=*[]*]] 12 [**--help**] 13 [**-i**|**--interactive**] 14 [**--privileged**] 15 [**-t**|**--tty**] 16 [**-u**|**--user**[=*USER*]] 17 CONTAINER COMMAND [ARG...] 18 19 # DESCRIPTION 20 21 Run a process in a running container. 22 23 The command started using `docker exec` will only run while the container's primary 24 process (`PID 1`) is running, and will not be restarted if the container is restarted. 25 26 If the container is paused, then the `docker exec` command will wait until the 27 container is unpaused, and then run 28 29 # OPTIONS 30 **-d**, **--detach**=*true*|*false* 31 Detached mode: run command in the background. The default is *false*. 32 33 **--detach-keys**="" 34 Override the key sequence for detaching a container. Format is a single character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. 35 36 **-e**, **--env**=[] 37 Set environment variables 38 39 This option allows you to specify arbitrary environment variables that are 40 available for the command to be executed. 41 42 **--help** 43 Print usage statement 44 45 **-i**, **--interactive**=*true*|*false* 46 Keep STDIN open even if not attached. The default is *false*. 47 48 **--privileged**=*true*|*false* 49 Give the process extended [Linux capabilities](http://man7.org/linux/man-pages/man7/capabilities.7.html) 50 when running in a container. The default is *false*. 51 52 Without this flag, the process run by `docker exec` in a running container has 53 the same capabilities as the container, which may be limited. Set 54 `--privileged` to give all capabilities to the process. 55 56 **-t**, **--tty**=*true*|*false* 57 Allocate a pseudo-TTY. The default is *false*. 58 59 **-u**, **--user**="" 60 Sets the username or UID used and optionally the groupname or GID for the specified command. 61 62 The followings examples are all valid: 63 --user [user | user:group | uid | uid:gid | user:gid | uid:group ] 64 65 Without this argument the command will be run as root in the container. 66 67 The **-t** option is incompatible with a redirection of the docker client 68 standard input. 69 70 # HISTORY 71 November 2014, updated by Sven Dowideit <SvenDowideit@home.org.au>