Search tools

Find a tool by name or what it does.

Docker Run to Compose Converter

Paste a docker run command and get the equivalent Compose service definition, with any flag it cannot map listed rather than dropped.

Quoted values, short flag clusters like -it, and backslash line continuations are all understood. Converted live, nothing leaves your browser.

Compose YAML

Your docker-compose.yml service will appear here.

How to convert a docker run command to Compose

  1. Paste the docker run command

    Enter the full command, including any backslash line continuations. It is tokenised properly, so quoted values and multi-line commands work.

  2. Review the Compose service

    The equivalent service definition appears live, with ports, volumes, environment variables, and other settings mapped to their Compose fields.

  3. Check for unmapped flags

    Any flag that has no direct Compose equivalent, or that is not recognised, is listed separately instead of being silently dropped.

  4. Copy or download the file

    Copy the YAML or download it as docker-compose.yml, ready to drop into a project.

Why use this tool

Proper command tokenising

The command is parsed the way a shell would read it: quoted values stay together, backslash line continuations are joined, and short flag clusters like -it are expanded correctly.

Broad flag coverage

Maps detach, name, published ports, volumes, environment variables, env files, networks, restart policies, working directory, user, entrypoint, labels, extra hosts, capabilities, devices, hostname, privileged mode, and memory and CPU limits.

Both flag styles supported

Both --flag value and --flag=value are read the same way, along with short-flag equivalents like -p, -v, and -e.

Unmapped flags called out

A flag with no direct field in a Compose service, or one this tool does not recognise, is listed with the reason instead of vanishing from the output.

Image-derived service name

The service key is taken from --name when given, or derived from the image name otherwise, so the file is ready to use without manual edits.

Runs entirely in your browser

The command you paste is parsed on your device. Nothing is uploaded, so internal image names and credentials in environment variables stay local.

About this tool

This tool reads a docker run command and produces the equivalent service block for a Compose file. It tokenises the command the way a shell would, so quoted values with spaces, backslash line continuations across several lines, and short flag clusters like -it all parse correctly instead of breaking on a naive split by spaces. Both --flag value and --flag=value forms are understood, along with the short forms such as -p, -v, -e, -w, and -u.

Detach, name, published ports, volumes, environment variables, env files, networks, restart policies, working directory, user, entrypoint, labels, extra hosts, added and dropped capabilities, devices, hostname, privileged mode, and memory and CPU limits are all mapped to their Compose fields. A trailing image and command are carried over too. Flags that this tool does not recognise, along with the handful that have no real equivalent in a persistent Compose service, such as detach and automatic removal, are listed separately with the reason, rather than being quietly dropped from the output.

Everything runs in your browser, so a command that embeds a private registry path or a secret passed with -e never leaves your device. To go the other way and check environment variables before they reach a container, use env to JSON; to build a content security policy header for the service you are containerising, see the CSP header generator.

Frequently asked questions

Which docker run flags does this understand?
-d, --name, -p/--publish, -v/--volume, -e/--env, --env-file, --network, --restart, -w/--workdir, -u/--user, --entrypoint, --label, --add-host, --cap-add, --cap-drop, --device, --hostname, --privileged, -i, -t, --rm, --memory, --cpus, plus a trailing image and command. Anything else is listed as an unmapped flag instead of being dropped.
Why do some flags show up as unmapped even though they are valid docker run flags?
A few flags, such as -d for detach and --rm for automatic removal, control how a one-off container is run rather than describing a persistent service, so there is no field for them in a Compose service definition. They still show up in the unmapped list with an explanation, rather than silently vanishing from the output.
Does it handle multi-line commands with backslash continuations?
Yes. A backslash at the end of a line is treated as a line continuation and joined with the next line before the command is tokenised, matching how a shell reads the same command.
What happens with a combined short flag like -it?
It is expanded into its individual flags, so -it is read the same as -i -t. If a cluster contains a flag with no Compose equivalent, such as the -d in -dit, that part is still reported separately.
How is the service name chosen?
If the command includes --name, that value becomes both the service key and the container_name field. Otherwise, the service key is derived from the image name, stripped of its registry path and tag.
Is my command sent anywhere?
No. Parsing and conversion both happen in your browser. The command, including any environment variables or paths in it, is never uploaded, stored, or logged.

Related tools