Docker Run to Compose
Convert a docker run command into a docker-compose service.
Paste a docker run command to convert it.
About the Docker Run to Compose
Paste a long docker run command and get the equivalent compose service definition. Once a command grows past a few flags it becomes unreadable and unrepeatable, and translating it by hand is exactly the kind of transcription that introduces mistakes.
How to use it
- 1 Paste your full docker run command, line continuations included.
- 2 The compose service definition is generated immediately.
- 3 Read any warnings — flags without a compose equivalent are reported, not dropped.
- 4 Copy the result into docker-compose.yml and run docker compose up.
What it does
- Ports, volumes, environment variables, labels and capabilities
- container_name, restart policy, user, working directory and entrypoint
- Handles both --flag value and --flag=value forms
- Respects quoted values containing spaces
- Reports unrecognised flags instead of silently discarding them
Frequently asked questions
What happens to flags the converter does not know?
They are listed as warnings so you can add them by hand. Silently dropping a --cap-add or --sysctl would produce a compose file that looks correct and behaves differently, which is worse than no conversion at all.
Why is -d not in the output?
Because detaching is a runtime choice, not a property of the service. Run docker compose up -d instead. The same applies to --rm, which has no compose equivalent — use docker compose down to remove containers.
Does it generate the version field?
No. The top-level version key has been obsolete since Compose V2 and current versions of Docker warn if it is present.
Will the generated file work as-is?
For straightforward commands, yes. Anything involving external networks, secrets, healthchecks or multiple containers needs hand-editing — a single docker run command simply does not contain that information.
Is my command sent anywhere?
No. Parsing and generation happen in your browser, so commands containing internal image names or environment values stay on your machine.