docker run
Creates a new container from an image and starts it, in one step.
In more detail
docker run is docker create plus docker start. Common flags: --rm deletes the container when it exits, -d runs it in the background, --name gives it a name, -p publishes a port, -e sets an environment variable, -v mounts a volume, -m and --cpus set limits. Anything after the image name replaces the image default command.
Examples
docker run --rm alpine:3.20 echo hellodocker run -d --rm --name m01l01-broker --network m01l01-net redpandadata/redpanda:v25.2.6 redpanda startRelated terms
- docker create — Prepares a container from an image, with its writable layer and settings, without starting it.
- docker start — Starts a container that already exists, keeping its writable layer and settings.
- --rm — A docker run flag that deletes the container automatically as soon as it exits.
- detached mode — Running a container in the background so your terminal is free straight away.
- port publishing — Forwarding a port on the host to a port inside a container so the service can be reached from outside.
- CMD — The Dockerfile instruction that sets the default command a container runs when you do not give one.
- container name — A human-readable name you give a container with --name, so you can refer to it without copying its ID.
Taught in
- Container Images The Exam Way — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Why Containers: Bare Metal, Machines And Processes — Docker Architecture & Production Containers
- Namespaces And Cgroups: Isolation And Limits — Docker Architecture & Production Containers
- Union Filesystems, Images And Writable Layers — Docker Architecture & Production Containers
- Docker, OCI, The Engine And The CLI — Docker Architecture & Production Containers
- Install Docker And Verify Your Environment — Docker Architecture & Production Containers
- Commands, Logs, Exec And Exit Codes — Docker Architecture & Production Containers
- Build Context, Dockerignore And Your First Dockerfile — Docker Architecture & Production Containers
- FROM, WORKDIR, COPY And ADD — Docker Architecture & Production Containers
- RUN, SHELL And Efficient Layer Caching — Docker Architecture & Production Containers
- ARG, ENV, LABEL, EXPOSE And VOLUME — Docker Architecture & Production Containers
- CMD, ENTRYPOINT, USER And Process Signals — Docker Architecture & Production Containers
- Multi Stage Builds, Targets And Build Secrets — Docker Architecture & Production Containers
- Tags, Digests And Reproducible Image References — Docker Architecture & Production Containers
- Authenticate, Tag, Push And Pull From A Registry — Docker Architecture & Production Containers
- Minimal Bases, Non Root Users And Smaller Images — Docker Architecture & Production Containers
- Scan, Patch And Inspect The Software Supply Chain — Docker Architecture & Production Containers
- Ephemeral Filesystems And Named Volumes — Docker Architecture & Production Containers
- Bind Mounts, Permissions And Backups — Docker Architecture & Production Containers
- Bridge Networks, DNS And Container Communication — Docker Architecture & Production Containers
- Port Publishing, Localhost And Network Troubleshooting — Docker Architecture & Production Containers
- Environment, Secret Files And Runtime Restrictions — Docker Architecture & Production Containers
- Health Checks, Dependencies And Reliable Startup — Docker Architecture & Production Containers
- Diagnose Crashes, Resource Limits And Unhealthy Containers — Docker Architecture & Production Containers
- Build, Test And Promote The Same Image In CI — Docker Architecture & Production Containers
- Harden And Deliver The Complete Service Stack — Docker Architecture & Production Containers
- Why A Log And Not A Queue — Apache Kafka & Event Streaming
- A Producer In Python — Apache Kafka & Event Streaming
- Losing A Broker — Apache Kafka & Event Streaming