Skip to main content

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.

✓ Live command preview ✓ Ports, volumes, env vars & flags ✓ Runs 100% in your browser

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.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$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.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →