09 / DevOps / docker-helpers
Docker Helpers
Generate docker run commands and docker-compose.yml files.
How to use
- 01Choose the output with the docker run / docker-compose.yml toggle.
- 02Enter the Image (for example nginx:1.27-alpine) and an optional Container / service name.
- 03Add Port mappings as host:container, Environment variables as KEY=value, and Volumes as host:container[:ro], one per line.
- 04Optionally set a Network and a Command override, tick Detached (-d) or Remove on exit (--rm), and pick a Restart policy.
- 05Press Copy to grab the result, or Download .yml in compose mode. Clear empties the text fields.
What is this tool?
Docker Helpers turns one set of container settings into either a ready-to-paste docker run command or an equivalent docker-compose.yml service. Values such as environment variables and volume paths are single-quoted for POSIX shells, and the command is split across lines for readability. Generation happens entirely in your browser, so image names and environment values never leave your machine.
docker run vs docker compose
docker run starts one container from the command line, with every option passed as a flag. It is ideal for a quick test, a one-off task, or a script. Docker Compose describes the same settings in a YAML file, so the configuration can be committed, reviewed, and started with docker compose up.
This tool maps the same inputs to both formats. Ports become -p flags or a ports list, KEY=value lines become -e flags or an environment map, volumes become -v flags or a volumes list, and a network becomes --network or a service networks entry plus a top-level networks declaration. The name is used as --name in docker run, and as both the service key and container_name in compose; without a name, the compose service is called app.
Docker restart policies and --rm explained
The restart policy decides what Docker does when a container exits. no never restarts, always restarts it whenever it stops, unless-stopped behaves like always but stays down after you stop it manually, and on-failure restarts only when the process exits with a non-zero code.
--rm deletes the container as soon as it exits, which suits throwaway runs. Docker has historically rejected --rm combined with a restart policy, so the generated docker run command drops --restart when Remove on exit is ticked. The compose output does not include -d or --rm, because detaching is chosen when you run docker compose up -d.
Example: an nginx container with a read-only volume
With the defaults, image nginx:1.27-alpine, name web, port 8080:80 and volume ./html:/usr/share/nginx/html:ro, the tool produces docker run -d --name 'web' --restart unless-stopped -p 8080:80 with two -e flags and the volume, followed by the image. The site is then served at localhost:8080 from your local html folder, and the :ro suffix keeps the container from writing to it.
The name, network, environment and volume values are wrapped in single quotes, with any embedded single quote escaped, so a value such as a password containing spaces or a dollar sign reaches the container exactly as typed instead of being expanded by the shell.
Common use cases
- Writing a docker run command for a README or runbook without missing quotes
- Converting a working docker run setup into a docker-compose.yml for a repository
- Spinning up a local database or web server for QA with ports and volumes mapped
- Showing teammates how environment variables and restart policies map between formats
FAQ
What does -p 8080:80 mean in docker run?
It publishes container port 80 on host port 8080. The host port always comes first.
What is the difference between always and unless-stopped?
Both restart the container after crashes and daemon restarts, but unless-stopped stays stopped if you stopped it manually.
Why is --restart missing from my docker run command?
Docker has historically rejected --rm combined with a restart policy, so the tool omits --restart when Remove on exit is checked or the policy is set to no.
Does the generated docker-compose.yml include a version key?
No. It starts with services, which is the format current Docker Compose expects; the version key is obsolete.
What does :ro mean on a volume?
It mounts the volume read-only inside the container, so the container cannot modify those files.
Are my environment values uploaded?
No. The command and YAML are generated locally in your browser.