Developer Tools
Docker Run to Compose Converter
Paste a docker run command and convert it to an equivalent docker-compose.yml service. Maps ports, volumes, env, restart, networks, and resource limits.
Docker run to docker-compose converter
Try a sample
What gets mapped
- -p to ports, -v to volumes (named volumes are declared at the top level), -e / --env-file to environment and env_file.
- --name, --restart, --network, --add-host, --cap-add, -w, --user, and the health-check flags each map to their Compose key.
- --memory and --cpus become a deploy.resources.limits block, which Compose v2 honors on up.
- The image, the container command after it, and an --entrypoint are kept verbatim.
Good to know
- Short flags can be bundled (-itd) and value flags accept both --name x and --name=x.
- --rm and -P have no Compose equivalent, so they are dropped with a note rather than guessed.
- The service name comes from --name, or from the image repository when no name is given.
- Everything runs in your browser. The command you paste, including any secrets in -e values, never leaves your device.
How to use
- Copy a docker run command from a README, Docker Hub, a tutorial, or your shell history.
- Paste it into the input box, or click a sample to see the format. Multi-line commands with trailing backslashes are fine.
- Read the generated docker-compose.yml on the right, with ports, volumes, environment, networks, and resource limits mapped to their Compose keys.
- Check the notes below the output for any flags that have no Compose equivalent or were not recognized.
- Copy the YAML, save it as docker-compose.yml, and run docker compose up -d.
About this tool
Docker Run to Compose Converter takes a docker run command, the kind you copy out of a project README, a Docker Hub overview, a tutorial, or your own shell history, and rewrites it as an equivalent docker-compose.yml service so the same container is reproducible from a file instead of a long one-off flag string. It is the inverse of the Docker Compose Generator: that tool builds a compose file from a form, while this one reads an existing command and translates it. The command is first tokenized with a POSIX-style shell tokenizer that understands single quotes, double quotes with backslash escapes, ANSI-C $'...' quoting, and backslash line continuations, so a multi-line command pasted with trailing backslashes parses correctly and a quoted value such as a health-check string stays intact. It then strips an optional leading sudo, the docker or podman program word, and the run, container run, or create subcommand, and walks the remaining arguments against a flag table. Short flags can be bundled (-itd), value flags accept both --name value and --name=value, the first bare token is treated as the image, and everything after it becomes the container command. The mapping covers the flags people actually use: -p to ports, -v to volumes (with plain-name sources promoted to top-level named volumes and bind-mount paths kept as written), -e and --env-file to environment and env_file, --name to container_name, --restart to the restart policy, --network to networks or network_mode, --add-host to extra_hosts, --cap-add and --cap-drop to cap_add and cap_drop, -w to working_dir, --user, --entrypoint, --privileged, --read-only, --init, -i and -t to stdin_open and tty, and the --health-* flags to a healthcheck block. Resource flags --memory and --cpus are emitted as a deploy.resources.limits block, which Compose v2 honors on up. The YAML is produced by a small deterministic writer that quotes only the values YAML requires (leading dash, colon, hash, empty string, YAML keywords like yes and no, strings that look like numbers, and dollar-prefixed references), matching the style of compose files Docker ships. Flags with no faithful Compose equivalent, such as --rm and -P, are dropped with an explanatory note instead of being silently guessed, and unrecognized flags are listed so nothing is lost without you knowing. Everything runs locally in your browser, so the command you paste, including any secrets in -e values, is never uploaded, logged, or stored.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
Docker Compose Generator
Build a multi-service docker-compose.yml with templates and live validation.
Open tool
DeveloperDockerfile Generator
Build a production Dockerfile with multi-stage build, non-root user, BuildKit cache, and healthcheck.
Open tool
DevelopercURL Command Parser
Decode curl: method, URL, headers, body, basic auth, cookies, and flag-by-flag explanations.
Open tool
ConverterYAML to JSON Converter
Two-way YAML and JSON converter with anchors, flow, and block scalars.
Open tool
Developersystemd Service Generator
Build a complete systemd .service unit file with presets, hardening, resource limits, and a companion timer.
Open tool
DeveloperNginx Config Generator
Build a production nginx server block with modern TLS, HTTP/2, HSTS, gzip, and proxy headers.
Open tool