Docker Run Command Builder
Build a complete docker run command visually — no syntax memorisation required. Configure port mappings, volume mounts, environment variables, restart policies, and flags like -d, --rm, and -it. The command updates live as you type.
Frequently Asked Questions
What does the -d flag do in docker run?▼
The -d (detached) flag runs the container in the background and prints the container ID. Without it, the container runs in the foreground and attaches your terminal to its output. Use -d for long-running services like web servers or databases.
What is the difference between --rm and stopping a container?▼
The --rm flag automatically deletes the container's filesystem once it exits. Without --rm, stopped containers remain on disk and can be restarted or inspected later. Use --rm for one-off tasks and short-lived containers to avoid accumulating stopped containers.
How do port mappings work with -p?▼
The -p flag maps a host port to a container port using the format host:container (e.g., -p 8080:80). Traffic arriving on port 8080 of your host machine is forwarded to port 80 inside the container. You can publish multiple ports by repeating the -p flag.
When should I use a named volume vs a bind mount?▼
Bind mounts (e.g., -v ./data:/data) map a specific path on your host into the container, making them ideal for development where you want live code changes. Named volumes (e.g., -v mydata:/data) are managed by Docker and are better for production data persistence because they are independent of the host directory structure.
What restart policies are available and when should I use them?▼
Docker offers four restart policies: 'no' (never restart, the default), 'always' (restart regardless of exit code, including on daemon start), 'unless-stopped' (like always but respects manual stops), and 'on-failure' (only restart on non-zero exit codes). Use 'unless-stopped' for services you always want running, and 'on-failure' for tasks that should retry on errors but not run indefinitely.
Related Products
on GumroadGitHub Actions CI/CD Templates Pack
12 production-ready GitHub Actions workflow templates covering Node.js, Python, Docker, multi-environment deployments, security scanning, and auto-changelog. Copy, paste, ship.
Buy on Gumroad →Developer Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →Developer Cheat Sheet Bundle
10 print-ready cheat sheets for the tools developers use every day: Git, Docker, Linux CLI, SQL, Regex, HTTP Status codes, VS Code shortcuts, Bash scripting, jq/JSON, and Markdown.
Buy on Gumroad →You Might Also Need
Dockerfile Linter
Paste your Dockerfile and instantly check for common issues: latest tags, missing HEALTHCHECK, running as root, cache-busting COPY order, ADD vs COPY, and multi-stage build suggestions.
Open free tool →
Dockerfile Generator
Interactive wizard to generate production-ready Dockerfiles for Node.js, Python, Go, Java, and Rust. Multi-stage builds, port config, custom layers.
Open free tool →
Docker Compose Generator
Generate docker-compose.yml configurations visually in your browser. Add services, ports, volumes, environment variables, and networks. Export production-ready YAML instantly. Free Docker tool.
Open free tool →
More Free Tools
Related Articles
Docker Compose vs Kubernetes: When to Use Each (2026)
A practical guide to choosing between Docker Compose and Kubernetes in 2026. Compare complexity, use cases, cost, and learn when to migrate from one to the other.
Docker Multi-Stage Builds: Reduce Image Size by 90% with Real Examples
Learn Docker multi-stage builds to dramatically reduce image size. Real examples showing 1.2GB → 23MB reduction for Node.js, Python, and Go applications.
Docker vs Kubernetes: When to Use Each (2025 Guide)
Docker vs Kubernetes 2025: key differences, Docker Compose vs Kubernetes, cost comparison, and a clear decision framework with real-world use cases.
Docker vs Podman: Container Runtime Comparison 2026
Docker vs Podman container runtime comparison 2026: architecture, security, performance, migration guide, and when to choose each container tool.
Docker Tutorial for Beginners 2026: From Zero to Running Containers
Learn Docker from scratch in 2026: installation, images, containers, volumes, Docker Compose, and real-world examples. Perfect for developer beginners.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →