commands.sh

docker container run

all

Run a command in a new Docker container.

More info →

Options (6)

boolean

Run command in a new container from a tagged image

Example: docker {{[run|container run]}} {{image:tag}} {{command}}
-d, --detachboolean

Run command in a new container in background and display its ID

Example: docker {{[run|container run]}} {{[-d|--detach]}} {{image}} {{command}}
boolean

Run command in a one-off container in interactive mode and pseudo-TTY

Example: docker {{[run|container run]}} --rm {{[-it|--interactive --tty]}} {{image}} {{command}}
-e, --envboolean

Run command in a new container with passed environment variables

Example: docker {{[run|container run]}} {{[-e|--env]}} '{{variable}}={{value}}' {{[-e|--env]}} {{variable}} {{image}} {{command}}
-v, --volumeboolean

Run command in a new container with bind mounted volumes

Example: docker {{[run|container run]}} {{[-v|--volume]}} /{{path/to/host_path}}:/{{path/to/container_path}} {{image}} {{command}}
-p, --publishboolean

Run command in a new container with published ports

Example: docker {{[run|container run]}} {{[-p|--publish]}} {{host_port}}:{{container_port}} {{image}} {{command}}

Examples (8)

Run command in a new container from a tagged image

docker [run|container run] image:tag command

Run command in a new container in background and display its ID

docker [run|container run] [-d|--detach] image command

Run command in a one-off container in interactive mode and pseudo-TTY

docker [run|container run] --rm [-it|--interactive --tty] image command

Run command in a new container with passed environment variables

docker [run|container run] [-e|--env] 'variable=value' [-e|--env] variable image command

Run command in a new container with bind mounted volumes

docker [run|container run] [-v|--volume] /path/to/host_path:/path/to/container_path image command

Run command in a new container with published ports

docker [run|container run] [-p|--publish] host_port:container_port image command

Run command in a new container overwriting the entrypoint of the image

docker [run|container run] --entrypoint command image

Run command in a new container connecting it to a network

docker [run|container run] --network network image
made by @shridhargupta | data from tldr-pages