Zero Signup ToolsFree browser tools

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

  1. Copy a docker run command from a README, Docker Hub, a tutorial, or your shell history.
  2. Paste it into the input box, or click a sample to see the format. Multi-line commands with trailing backslashes are fine.
  3. Read the generated docker-compose.yml on the right, with ports, volumes, environment, networks, and resource limits mapped to their Compose keys.
  4. Check the notes below the output for any flags that have no Compose equivalent or were not recognized.
  5. 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

All tools
All toolsDeveloper Tools