Embed this tool on your site
<iframe src="https://devtoolbox.dedyn.io/tools/docker-run-builder" width="100%" height="800" frameborder="0" title="Docker Run Command Builder"></iframe>

Docker Run Command Builder

Build docker run commands visually. Fill in the form below and the command updates in real time. Use preset templates for common setups or configure every option manually.

Presets:

Port Mappings (-p)

Volume Mounts (-v)

Environment Variables (-e)

Options

Generated Command

docker run <image>

How to Use the Docker Run Builder

This tool generates docker run commands from a visual form. Start by entering an image name, then add ports, volumes, environment variables, and other options. The command updates in real time as you make changes.

Use the preset templates to quickly populate the form for common services like Nginx, PostgreSQL, Redis, MySQL, Node.js, and Flask. You can then customize any preset to match your exact requirements. The generated command includes proper quoting and ordering of flags.

Common Docker Run Patterns

Frequently Asked Questions

What is the docker run command?
The docker run command creates and starts a new container from a Docker image. It supports flags for port mapping (-p), volume mounts (-v), environment variables (-e), network configuration (--network), resource limits (--memory, --cpus), detached mode (-d), and many other options. This builder generates the full command visually.
What is the difference between -d and -it in docker run?
The -d flag runs the container in detached mode (background), returning the container ID immediately. The -it flags combine -i (interactive, keeps STDIN open) and -t (allocates a pseudo-TTY), which is used for interactive sessions like running a shell inside the container. You typically use -d for services and -it for debugging or running commands.
How do Docker port mappings work?
Docker port mappings use the -p flag with the format HOST_PORT:CONTAINER_PORT. For example, -p 8080:80 maps port 8080 on your host machine to port 80 inside the container. You can also bind to a specific IP with -p 127.0.0.1:8080:80, or let Docker assign a random host port with -p 80 (container port only).
What does --rm do in docker run?
The --rm flag automatically removes the container when it exits. This is useful for one-off commands, testing, or temporary containers where you do not want leftover stopped containers cluttering your system. Without --rm, stopped containers remain and must be manually removed with docker rm.
How do I set resource limits for a Docker container?
Use --memory (or -m) to set a memory limit, for example --memory 512m for 512 megabytes or --memory 2g for 2 gigabytes. Use --cpus to limit CPU usage, for example --cpus 1.5 to allow one and a half CPU cores. These limits prevent a single container from consuming all host resources.
What restart policies are available in Docker?
Docker supports four restart policies: 'no' (default, never restart), 'always' (always restart regardless of exit code), 'unless-stopped' (restart unless manually stopped), and 'on-failure' (restart only on non-zero exit code, optionally with a max retry count). Use 'unless-stopped' or 'always' for production services.
Keyboard Shortcuts
Ctrl+Enter Copy command
Ctrl+Shift+C Copy command
Ctrl+L Reset form