Developer Tools

Docker Run to Compose

Give a long docker run command a readable Compose service. The converter understands POSIX-style quoted arguments, generates YAML with a serializer, and stops on unsupported flags so omissions remain visible.

Free online tool

Loading tool…

POSIX-style quoting and backslash line continuations are supported. Commands are parsed locally and never executed. Replace shell variables with concrete values.

Detached mode is a launch option: use docker compose up -d.

Review paths, credentials, exposed ports, and runtime options before using this file. Validate it with docker compose config. Relative bind paths resolve from the Compose file location. Named volumes are declared; existing custom networks are referenced as external networks.

Commands and generated YAML stay in your browser.

GET STARTED

How to use the Docker Run to Compose

  1. 01

    Paste one docker run or docker container run command. Replace shell expansions with concrete values.

  2. 02

    Choose a service name and review generated settings and conversion notes.

  3. 03

    Copy or download compose.yaml, inspect it, and validate it with docker compose config before running it.

Examples

Web server with a volume

docker run -d -p 8080:80 -v web-data:/usr/share/nginx/html:ro nginx:alpine creates a service with a published port, a read-only volume mount, and a declared named volume.

Quoted environment values

docker run -e MESSAGE="hello world" alpine printenv MESSAGE keeps the environment value as one argument and preserves the container command as an argument list.

Supported Docker options

Common supported settings include ports, volumes, environment variables and files, labels, restart policy, hostname, user, working directory, entrypoint, networks, memory, CPUs, platform, capabilities, DNS, extra hosts, exposed ports, devices, security options, tmpfs, read-only mode, init, interactive input, and TTY. Detached mode and --rm produce notes because they affect how you launch a container rather than a persistent service setting. Other flags stop conversion with their names shown.

Quoting, variables, and existing resources

Single and double quotes group arguments; backslashes escape characters using a POSIX-style shell model. Shell substitutions, pipelines, and redirection are rejected and never executed. Literal dollar signs are doubled in YAML to avoid Compose interpolation. Named volumes are declared. A custom Docker network is mapped to an external Compose network. Bind paths, environment files, and external resources must exist where Compose will run.

What to know

  • One docker run command at a time; 50,000-character limit.
  • No arbitrary shell evaluation or complete Docker CLI coverage.

Common questions

Can I convert a PowerShell or Windows CMD command?

The parser follows POSIX-style quoting. PowerShell backticks, CMD caret escapes, and shell-specific expansions are not supported. Rewrite the command with literal values and POSIX quoting first.

Why did an unsupported flag stop everything?

Silently removing a security, storage, or runtime option can change container behavior. The tool returns no partial YAML when it cannot map an option.

Will this run my container?

No. The command is only parsed into a local text document. Review the file and use your own Docker installation to validate and run it.

Sources & references