Skip to main content

Docker Run ↔ Compose Converter

Convert docker run commands to Compose YAML and back, with a report of what converted

docker run Input

Up to 256 KB. Commands are parsed, never executed.

Options

Indentation

Compose Output

Paste one or more docker run commands, or load an example.
Paste one or more docker run commands, or load an example.

How to use it

  1. 1.Choose Docker Run → Compose or Compose → Docker Run.
  2. 2.Paste commands or a Compose file, open a file, or load an example.
  3. 3.Pick the Compose target, indentation or command layout.
  4. 4.Read the conversion report under the output, then copy or download the result.

What does the converter do?

It turns docker run commands into a Compose file and turns a Compose file back into docker run commands. Both directions go through one normalized container model instead of text rewriting, so ports, volumes, environment variables, networks, health checks, resource limits and quoting are understood rather than copied. Every flag or key lands in a report as Exact, Approximate or Unsupported, so nothing is dropped silently.

What converts exactly

Ports with host IPs, ranges and protocols; -v and --mount volumes; environment variables with quotes, spaces and dollar signs; restart policies; user-defined networks with aliases and static IPs; health checks, logging, ulimits, capabilities, devices and most resource flags. Literal dollar signs become $$ so Compose does not treat them as variables, while $VAR references stay variables. Several commands, separated by blank lines, semicolons or &&, become several services, named after --name, then the image name.

Limits and privacy

depends_on, profiles, build, secrets, configs and most deploy settings have no docker run equivalent and are reported instead of converted. Compose prefixes networks and volumes with the project name, while docker run does not; the report says when that matters. Commands are parsed, never executed, and input is limited to 256 KB. Pasted commands and files are not saved; only your display preferences are remembered.

Frequently asked questions
Does the converter run my docker commands?
No. Commands are tokenized and parsed in your browser, never executed. Command substitutions such as $(id -u) are kept as literal text and reported, and pipes or redirects are ignored with a note.
Why are some flags marked Approximate or Unsupported?
Docker run and Compose do not describe exactly the same things. --rm, --gpus and links convert with different behaviour, while flags like --cidfile and keys like depends_on or build have no counterpart. Each one is listed with its flag or key path and the reason, so nothing is lost silently.
Should a new Compose file include version: 3.8?
No. The current Compose Specification ignores the version field, so the default output omits it. Choose the Legacy target only for older tools that still require it.

CodingTool is officially live on