Documentation

Official Docker command reference & glossary.

docker run

Container

Create and start a new container from an image.


Syntax

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Details

The `docker run` command is the primary way to start containers. It creates a writeable container layer over the specified image and prepares it for running the specified command.

Examples

Run a container in the background (detached)

docker run -d nginx

Run with port mapping (Host:Container)

docker run -p 8080:80 nginx

Run with an interactive shell

docker run -it ubuntu bash

Run with a named volume

docker run -v my_data:/data alpine

Run and remove container after exit

docker run --rm alpine echo "Quick job"