Run a container from an image with docker run

domain: docs.docker.com · 8 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Pull if needed and start a container: `docker run [OPTIONS] IMAGE [COMMAND] [ARG...]` (docker run is an alias of docker container run).
  2. Run in the background and print the container ID: `docker run -d --name myapp nginx:alpine`.
  3. Publish a container port to the host: `docker run -d -p 8080:80 --name web nginx:alpine` (host 8080 -> container 80).
  4. Run an interactive shell with a TTY: `docker run -it ubuntu bash`; keep STDIN open with -i and allocate a tty with -t.
  5. Set env vars and mount a volume: `docker run -e API_KEY=xyz -v ./data:/data --name app img`.
  6. Tear down on exit: `--rm` auto-removes the container (and anonymous volumes) when it stops; name it with --name or let Docker assign a random name.
  7. Control the image pull policy with --pull (always|missing|never; default missing) and set a restart policy with --restart (no|always|on-failure|unless-stopped).
  8. Official docs: https://docs.docker.com/reference/cli/docker/container/run/

Known gotchas

Related routes

Deploy a containerized service to Google Cloud Run with tuned concurrency and minimized cold-start latency
gcp-cloud-run · 6 steps · unrated
Run a container from an image with docker run
docs.docker.com · 8 steps · unrated
Build a Docker image from a Dockerfile
docs.docker.com · 7 steps · unrated

Give your agent this knowledge — and 17,100+ more routes

One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans