Docker: Run containers
3 Docker commands: Run containers. Click a command to see what each part does.
Docker: Run containersIndex
- Whole sheet120
- Basics: images & containers11
- Volumes & networks4
- Find & inspect containers7
- Environment variables & container config12
- Software versions inside containers & images9
- Logs & shells5
- Run containers3
- Images4
- Cleanup6
- Docker Compose v27
- Container lifecycle & live changes10
- Builds, multi-platform & moving images11
- Volumes, networks & remote hosts in depth12
- Compose: more commands9
- Swarm mode10
Run containers3
docker run -d --name <name> -p <host-port>:<container-port> <image>:<tag>Run a service in the background with a port and a nameWhat each part does
docker runcreate and start a container-d--detach: run in the background and print the ID--name <name>give it a fixed name instead of a random one-p <host-port>:<container-port>publish a container port on the host (binds all interfaces; use 127.0.0.1:<host-port>:… for local only)<image>:<tag>image to run (pin a tag, avoid latest)
docker run -it --rm <image> shThrow-away interactive containerWhat each part does
-itinteractive + terminal--rmdelete the container (and anonymous volumes) when it exitsshcommand to run instead of the image default
docker run -d -e <KEY>=<value> --env-file .env -v <host-path>:<container-path>:ro -m 512m --cpus 1 --restart unless-stopped <image>Env vars, volume and limitsWhat each part does
-e <KEY>=<value>set one environment variable--env-file .envload KEY=value lines from a file-v <host-path>:<container-path>:robind-mount a host folder, read-only-m 512mmemory limit (exceeding it → OOM kill, exit 137)--cpus 1at most one CPU worth of time--restart unless-stoppedrestart automatically unless you stopped it yourself
Nothing matches.
My DevOps Playbook by Angelo John Calleja