Task path / input to outcome
How to convert a docker run command to Compose
- 01
Paste the docker run command
For literal POSIX shell commands targeting Linux containers. Maximum 64 KiB UTF-8. Raw env files require Compose 2.30+. This is a configuration draft; no shell, Docker daemon or image is executed or inspected. Use one literal docker run command. Replace host variables with explicit values; quote literal $ in single quotes or escape it. Shell expansion, pipes, redirects, command substitution and unescaped line breaks are not supported. Backslash line continuation is supported.
- 02
Convert to a Compose service
Convert name, ports, explicit environment values, raw env files, mounts, restart, network, workdir, user, entrypoint and labels. -i/-t (including -it) become stdin_open/tty. Short options accept attached values and long options accept =value. Unknown options stop conversion.
- 03
Check the generated YAML
Arguments after the image retain their order and empty strings in the command list. A nonempty entrypoint stays one argument; an empty entrypoint clears it. Literal dollar signs are doubled for Compose, preserving their value instead of interpolating the host environment. The default network is explicitly bridge. Bind mounts keep the difference between -v (may create a host directory) and --mount (must exist).
- 04
Review the unsupported list
An option is not supported. No partial YAML was generated. Use the supported options listed in the guide; move container command arguments after the image. --rm is not represented in YAML. Choose the appropriate Compose run/removal lifecycle yourself. -d/--detach is a launch option: use docker compose up -d when appropriate.
- 05
Copy or download the YAML
env_file uses raw format (Compose 2.30+) to preserve dollar signs and quotes. Relative paths resolve beside compose.yaml. File contents and unset variables are not inspected; review the actual environment. Named volumes and custom networks are external references with their original names. They must already exist before launch; no resources are created or checked here.