Docker Run to Compose

Paste a docker run command and get a ready-to-use Compose service definition: ports, volumes, environment, networks, healthcheck and restart policy, converted in your browser.

Turn a long docker run command into a Compose file you can commit. Paste the command exactly as you would type it, including line continuations. Flags with no Compose equivalent are listed as notes rather than silently dropped.

From an ad-hoc command to a reproducible file

Why the translation is not purely mechanical

A docker run command and a Compose service describe the same container, but they answer different questions. The command says what to do right now. The file says what should be true whenever this service is running. Most flags map across cleanly, and the ones that do not are almost always the ones that describe the act of running rather than the container itself.

The clearest example is detach. Writing -d tells the daemon not to hold your terminal, which is a property of that invocation, not of the service. In Compose the same intent is expressed at the command line with docker compose up -d, so the flag simply disappears from the file. The same applies to --rm, which asks for cleanup after this particular run; the Compose equivalent is running docker compose down when you are finished.

Interactive flags sit in between. Both -i and -t do have Compose keys, stdin_open and tty, because keeping a shell attached can be a genuine property of a service. They are converted rather than dropped, though most long-running services do not need them.

Quoting is where conversions break

The single most common cause of a broken conversion is a shell quote that got lost before the command was pasted. Consider a healthcheck: the whole test command has to arrive as one argument, which is why it is wrapped in quotes on the command line. Paste it without the quotes and the words become separate arguments, the image name is read from the wrong position, and the result is nonsense.

The converter tokenises the input the way a shell would, honouring single quotes, double quotes, backslash escapes and backslash-newline continuations, so a command copied straight out of a script keeps its structure. It then re-quotes values on the way out according to YAML rules, which matters more than people expect. A port mapping such as 8080:80 must be quoted in YAML, because an unquoted colon-separated pair is ambiguous and older parsers have historically read values like 22:00 as a sexagesimal number.

Networks, and what the file cannot know

Network handling is the one place where a faithful conversion still needs a decision from you. If the command joins host, none or bridge, that is a mode and becomes network_mode. Any other name refers to a network that already exists, so the service gets a networks entry and the file declares that network as external.

That declaration is a statement about your environment: it says the network is managed outside this file. If you would rather Compose create and own the network, delete the external flag and let it be defined normally. The converter cannot tell which you want, because the original command only proves the network existed at the moment it ran.

The same caution applies to bind mounts. A path such as /srv/site works on the machine where the command was written and nowhere else. Once the service lives in a file that gets committed and shared, relative paths or named volumes are usually the better choice.

Built in-house with a hand-written shell tokeniser and YAML writer. No third-party parser is bundled and your command never leaves the browser.

Frequently asked questions

Why did the -d flag disappear from the output?
Detach describes how you start a container, not what the container is. In Compose you express the same thing by running docker compose up -d, so it does not belong in the file.
Can I paste a multi-line command with backslashes?
Yes. Backslash-newline continuations are joined before parsing, so you can copy a command straight out of a shell script or documentation without reformatting it.
Why are my ports wrapped in quotes?
YAML treats an unquoted colon-separated pair as ambiguous, and some parsers read values like 22:00 as a number. Quoting port mappings is the documented way to keep them exact.
What does external: true mean on the generated network?
It tells Compose the network already exists and should not be created or removed by this file. If you want Compose to manage the network itself, remove that flag.
Are unsupported flags silently ignored?
No. Anything the converter cannot map is listed under conversion notes so you can decide what to do with it, rather than discovering the omission later.
Is my command uploaded anywhere?
No. Parsing and YAML generation both run in your browser with hand-written code, so the command never leaves the page.