Docker Run to Compose Converter
Found a docker run command in the docs but want it in your Compose stack? Paste it here and get the YAML, with unrecognised flags called out so nothing is lost.
…
Handles the common flags: --name, -p, -v, --mount, -e, --env-file, --restart, --network, --user, --cap-add, --device and more. Anything it does not recognise is listed below the output so you can add it by hand — nothing is silently dropped.
How Docker run flags map to docker-compose.yml
A docker run CLI command and a docker-compose.yml file send the exact same instructions to the Docker daemon—Compose simply expresses them in structured YAML you can version-control. Flags like --name map to container_name, -p 8096:8096 becomes a list item under ports:, -v host:container moves into volumes:, -e KEY=VAL sits under environment:, and --restart unless-stopped becomes restart: unless-stopped.
Keeping services in Compose eliminates long shell one-liners and makes future updates repeatable: changing an environment variable or volume path takes two seconds in an editor and one docker compose up -d.
Step-by-step example: turning an uptime-kuma command into Compose
Take a typical installation snippet from a project README and convert it into a permanent stack directory.
- Paste
docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1into the input box. - Review the generated YAML: check that the top-level
volumes:declaration is created foruptime-kuma. - Save the output as
/srv/docker/uptime-kuma/docker-compose.ymland start it withdocker compose up -d.
Result: Instead of retyping flags from browser bookmarks during upgrades, docker compose pull && docker compose up -d updates the container in place with zero lost settings.
Frequently Asked Questions
Do I still need the version: line at the top of docker-compose.yml?
No. Docker Compose v2 (docker compose with a space) treats the top-level version field as obsolete and prints a warning if you include it. Start directly with services:.
What happens if the original docker run command includes --network my-proxy?
Compose requires pre-existing networks to be declared with external: true under the top-level networks block, or created beforehand with docker network create my-proxy before running docker compose up -d.
Why are flags like --rm omitted or flagged in Compose?
The --rm flag tells Docker to delete a one-off container immediately after it exits, whereas Docker Compose is built for persistent services managed with restart policies. For one-off jobs, run docker compose run --rm instead.