Skip to main content

docker run → docker-compose

Developer

You copied a `docker run` line from the docs, it worked, and now you want it in a compose file. Retyping it by hand is how `-e` flags get dropped or a volume path gets reversed. This tool tokenises the command like a shell, maps each flag to its compose key, and turns the trailing command into `command:`. Flags it does not recognise are kept as comments rather than silently discarded — silent loss is the real hazard here.

Loading tool…

How to use

4 steps
  1. 01

    Paste the full command including `docker run` and press Convert.

  2. 02

    Both `--flag=value` and `--flag value` forms work, as do quoted arguments and trailing backslash line continuations.

  3. 03

    The `# unrecognised flags` comment block is intentional: `--memory` and `--cpus` need compose-version-specific syntax, so leaving them to you beats guessing.

  4. 04

    Download the result as `docker-compose.yml` and add the top-level `volumes:` declarations where needed.

Technical Notes & Guide

1

Quote your port mappings

`8080:80` parses fine unquoted, but `127.0.0.1:8080:80` and IPv6 addresses can be read by YAML as nested mappings, producing confusing errors. Writing `- "8080:80"` always is the cheap habit; this tool quotes ports and volumes for you.

FAQ

2 questions
Q1Why is there no version field?

Compose V2 deprecated `version` and warns when it is present. If you are still on Compose V1, add `version: "3.8"` yourself.

Q2Can it merge several containers?

Convert one service at a time, then merge the service blocks. Guessing dependencies between containers would do more harm than good.

Developer