Skip to content
gohacks.dev
DevOps

docker run to Docker Compose

Paste a docker run command and get the equivalent compose.yaml service: ports, volumes, environment, restart policy, healthcheck, networks and more.

Free · No sign-up · Your inputs stay in your browser

Input

Convert docker run to Docker Compose

Output

compose.yaml

395 characters

Written for the Compose Specification, so there is no version: key (Compose v2 ignores it and warns). Named volumes are declared at the bottom; networks given with --network are assumed to exist already and marked external. Start it with docker compose up -d.

Runs in this browser. Nothing you paste is sent to a server.

Why move to Compose

A long docker run line lives in shell history or a README and drifts. A compose.yaml is versioned with the project, starts the whole stack with docker compose up -d and recreates only what changed. The file format is the Compose Specification; the top-level version: key is obsolete and ignored.

Things to check

Compose prefixes names with the project, so a named volume called redis-data becomes myproject_redis-data, a different volume from the one docker run created. Declare it external: true to reuse existing data. Shell substitutions such as $(pwd) are not evaluated in Compose files; use a relative path like ./ instead.

Share

Frequently asked questions

Is docker-compose.yml or compose.yaml the right name?
Both work. compose.yaml is the name the Compose Specification prefers, and docker compose looks for it first.
Why do my ports work with docker run but not Compose?
Check that the service is attached to the network you expect and that a host port is given: "8080:80" publishes, while "80" alone picks a random host port.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools