Docker Run to Compose

Convert docker run commands into a compose.yaml with ports, volumes and env.

About this tool

Paste one or more docker run commands, such as the ones in a project's README. Each becomes a service in a single compose.yaml, named after --name or the image. Named volumes and networks are declared at the bottom, and anything without a Compose equivalent is listed rather than guessed. Copy the YAML or download compose.yaml.

From docker run to Compose

A long docker run command is easy to copy but hard to maintain: it isn't saved anywhere, it's awkward to edit, and running several containers means remembering several commands. Docker Compose stores the same settings in a YAML file, so docker compose up -d starts everything and the file lives in version control. Most flags translate directly. -p 8080:80 becomes a ports entry, quoted as Compose recommends. -v and --mount become volumes, and named volumes such as pgdata are declared at the top level. -e and --env-file become environment and env_file. --restart, --name, -w, -u, --entrypoint, labels, capabilities, devices, DNS, ulimits, sysctls and logging options all have direct keys. --network host becomes network_mode: host, while a named network becomes an external network, because docker run expects it to exist already. -it maps to stdin_open and tty, --gpus all to an NVIDIA device reservation, and the health-check flags to a healthcheck block. Anything after the image becomes the command. Containers in one Compose file share a network and can reach each other by service name, so --link isn't needed. Honest limits: --rm and -P have no Compose equivalent, and passwords typed after -e end up in the file, so move them into an .env file. The obsolete top-level version: key is left out. YAML to JSON, JSON to YAML and the .gitignore generator are related.

Frequently asked questions

How do I convert a docker run command to docker-compose?

Paste the command here. Each flag is mapped to its Compose key and you get a compose.yaml to start with docker compose up -d.

Can I convert several containers at once?

Yes. Paste several docker run commands, one per line or block, and each becomes a service in the same file.

Do I still need a version: line in compose.yaml?

No. Docker Compose v2 ignores it, so the converter leaves it out.

Is anything executed?

No. The tool only parses the text in your browser. Nothing runs and nothing is sent.