Docker Run to Compose
Convert a `docker run` command into a docker-compose service definition, locally.
Turn a long docker run command into a compose service
A `docker run` line with several `-p`, `-v` and `-e` flags is awkward to store or hand to a teammate, while a docker-compose.yml service is easy to diff and check in. This tool tokenizes your command, recognizes the common flags, and writes out an equivalent service definition under a name taken from `--name` or the image itself. Since a real run command often carries a database URL or API key in an `-e` flag, parsing happens locally rather than on a server.
How to use the Docker Run to Compose
- Paste a full `docker run ...` command into the left editor, or click Example to load a sample.
- Read the generated docker-compose.yml service block on the right as you type.
- Check that ports, volumes, environment variables and the restart policy landed under the right keys.
- Fix or extend the command on the left; the output regenerates on every change.
- Copy the YAML, or use Send To to hand it to another tool such as the YAML/JSON converter.
Recognized flags include --name, -p/--publish, -v/--volume, -e/--env, --env-file, --restart, -w/--workdir, --network, --entrypoint, -u/--user, --label, --hostname, -m/--memory and --cpus, mapped to their docker-compose equivalents such as ports, volumes, environment and mem_limit.
Flags with no compose equivalent, like -d, --rm, -i, -t and --init, are recognized and silently dropped rather than guessed at; any other unrecognized flag is skipped the same way, so double-check the output against flags the converter doesn't list.
Frequently asked questions
- Which docker run flags does this convert?
- Image, --name, port and volume mappings, environment variables and env files, --restart, --workdir, --network, --entrypoint, --user, --label, --hostname, --memory, --cpus and a trailing command; anything else is left out of the generated YAML.
- What happens to flags like -d, --rm or -it?
- They are recognized as flags with no docker-compose equivalent, such as detach mode or auto-remove, and are simply omitted from the output rather than mapped to something incorrect.
- Is it safe to paste a docker run command with an API key in an -e flag?
- The command is tokenized and converted entirely in your browser using local string parsing, so an environment variable or credential passed via -e never leaves the page, but avoid pasting real secrets into shared or untrusted browser tabs regardless.
- How is the compose service name chosen?
- It uses the value passed to --name if present, otherwise it takes the image name, strips any registry path and tag, and uses what's left, so nginx:alpine from ghcr.io/foo/nginx:alpine would become the service name nginx.