Docker Command Generator

Pick run, build, compose, or exec, then fill in the image, ports, volumes, and flags. The command, Dockerfile, and compose file update together, so you copy whichever one the terminal in front of you needs.

Command
Preset

Image & name

Port mappings

:

Environment variables

Volume mounts

Options

Network

  • 4 command types
  • Command, Dockerfile, compose together
  • Runs entirely in your browser

Getting the flags right without reading the whole manual

The Docker CLI has close to sixty flags on run alone, and most people only need eight or nine of them in a normal day. This page fills in a form instead, and the table below explains what each flag you can toggle changes, including the two that cause the most confused bug reports: port order and the interaction between --rm and -d.

What each flag in the generated command does

FlagEffectWatch for
-dRuns the container in the background and returns the prompt right awayCombine it with --rm for a container you plan to inspect, and any crash log disappears with the container
-i -tOpens a pseudo terminal and keeps standard input attachedNeeded for an interactive shell, unnecessary on a web server or database that only listens on a port
--rmDeletes the container the moment it stopsNothing to restart or inspect afterward, so pair it with detached mode only when you are done debugging
--privilegedGives the container the same device access as the hostAlmost never required for a web app or database image, treat a request for it as a reason to check what the image needs
--nameAssigns a fixed, reusable name to the containerA second run with the same name fails until the first container is removed with docker rm
-p host:containerMaps a port on your machine to a port inside the containerHost port comes first. Swap the two and the service stays unreachable even though the container is running
-e KEY=valueSets an environment variable inside the containerVisible in docker inspect and to anyone with shell access to the host, so this field is for configuration, not production secrets
-v host:containerMounts a path from your machine into the containerA relative path only resolves if the drive is shared with Docker Desktop first, see below
--networkAttaches the container to a mode or a named networkHost mode skips port mapping entirely, so filling in ports above has no effect once host is selected

Port order is the single most common mistake on this page.-p 8080:80 means visitors reach the container on your port 8080, and the container itself listens on 80. Write it backwards as -p 80:8080 and Docker binds port 80 on your machine to a port the container is not using, so the app looks broken even though the container starts fine.

Run, build, compose, and exec answer four different questions

The four buttons at the top are not variations of one command, they are separate operations that happen to share a form.

Reading the Dockerfile tab

The Dockerfile tab looks at your image name and picks one of three short templates: Node, Nginx, or a generic fallback for everything else. It is a starting point for a quick test, not a production build. A real image usually needs a multi-stage build, a non-root user, and a pinned base tag, none of which this shortcut adds.

For anything you plan to deploy, build the Dockerfile with the dedicated Dockerfile Generator instead, which covers multi-stage builds and a non-root user by default.

Network modes in one table

ModeWhat it doesTypical use
DefaultDocker's standard bridge network, with the ports you mapped published to the hostAlmost every single-container setup
BridgeSame as default, written explicitly with --network bridgeScripts that prefer an explicit flag over Docker's implicit choice
HostShares the host's network stack directly, no port mapping involvedNative Linux hosts needing the lowest possible network overhead. On Docker Desktop for Mac or Windows it behaves differently and rarely does what people expect
NoneNo network interface at all beyond loopbackA batch job or CLI tool that never needs to send or receive network traffic
CustomJoins a named network you created with docker network createLetting several containers reach each other by container name instead of an IP address

Volume paths and the Windows drive-sharing catch

A bind mount like ./data:/var/lib/data only works if Docker Desktop has been granted access to the drive the path sits on. On Windows and macOS this is a setting inside Docker Desktop, not something a browser page can check or set for you. If a mount silently shows an empty folder inside the container, that setting is the first place to look, followed by confirming the host path exists before the container starts.

Limits worth knowing before you rely on this

Everything above runs as JavaScript in this tab. No image is pulled, no container starts, and no field you fill in leaves the page, since generating a command is string building in the browser. Copy the result into a terminal to run it, and nothing you typed is kept once you close the tab.

Docker command questions that come up in review

Port order, the exec tab, privileged mode, and what the compose output does and does not cover.

Why does my docker run command fail with "port is already allocated"?

Another container or local process already holds the host port you chose. Run docker ps to see which container is using it, stop it, or change the host side of the mapping here to a free port such as 8081. The container side of the mapping can stay the same since that port only exists inside the container.

What is the difference between the Build tab and the Dockerfile tab?

The Build tab writes the command that turns a Dockerfile into an image, docker build -t image followed by a dot for the current directory. The Dockerfile tab writes the file that command reads. You need both: the file next to your code, and the command run from that same folder.

Why does the Exec command say "No such container"?

Exec attaches to a container that is already running, it does not start a new one. Run docker ps first and copy the exact name or ID shown there into the container name field. A stopped container, or a name that was never started, will always fail this way.

Should I turn on Privileged mode?

Almost never for a typical web app, API, or database container. Privileged mode gives the container the same access to devices and kernel features as the host machine, which removes most of the isolation Docker exists to provide. Reach for it only when a specific tool documents that it requires privileged access, such as certain hardware or virtualization workloads.

Can I use a relative path for a volume mount?

Yes, something like ./data:/var/lib/data works on Linux directly. On Windows or macOS with Docker Desktop, the drive containing that path needs to be shared with Docker first, in Docker Desktop settings. A mount that resolves to an empty folder inside the container usually means that sharing setting, not the path text, is the problem.

Does the Compose tab support more than one service?

No, it writes a single service block from the image, ports, environment variables, and volumes already in the form. For an app plus a database plus a cache in one file, either run this tool once per service and merge the blocks by hand, or use the Docker Compose Generator, built for multi-service stacks.

Are the environment variable values I type here safe to use for passwords?

No. Values entered here appear as plain text in both the command output and the file output, and plain text environment variables are visible to anyone who can run docker inspect against the container. Use Docker secrets, a mounted file with restricted permissions, or your platform vault for anything that needs to stay confidential.

Which network mode should I pick?

Default, which is the same as explicit bridge mode, covers most single-container setups and is the safe choice if you are unsure. Reach for a custom named network when several containers need to find each other by name. Host mode is a native Linux feature that behaves differently on Docker Desktop, so avoid it there unless a specific guide tells you to use it.

Is anything I type here sent to a server?

No. Building the command, the Dockerfile text, and the compose file all happen in JavaScript running in your browser. Nothing is pulled, started, or uploaded, and nothing you enter is stored once you leave or reload the page.