docker run
docker run [options] <image> [command]
Risk: Safe
What it does
Makes a new container from an image and starts it.
When to use it
Every time you want to run an app in a box.
Example
$ docker run -d --name web -p 8080:80 nginx:1.30-alpineRun nginx in the background. Open hatch 8080.
$ docker run hello-worldYour first container: it prints a hello.
$ docker run --rm alpine:3.22 echo hiRun once, then clean the box away.
$ docker run -it alpine:3.22 shGet a shell inside. Type exit to leave.
$ docker run -d -e POSTGRES_PASSWORD=secret postgres:18-alpineGive the app a setting with -e.
$ docker run -d -v pgdata:/var/lib/postgresql postgres:18-alpineKeep data in a locker (volume).
Learn it in: Your first docker run · Official docs