1001Ferramentas
🐳 Dev

Docker Run → Compose

Convert a docker run command to the equivalent docker-compose.yml automatically. Maps ports, volumes, environment variables, networks and restart policies.

Exemplos:

Flags suportadas

--name → container_name -p / --publish → ports -v / --volume → volumes -e / --env → environment --network → networks --restart → restart --entrypoint → entrypoint -u / --user → user -w / --workdir → working_dir -l / --label → labels --hostname → hostname --memory / -m → mem_limit

From a one-off command to versioned Compose

That container you started with a five-line docker run works fine, but the command lives in your shell history and nobody else can reproduce it. Paste the command here and get the equivalent docker-compose.yml: ports, volumes, environment variables, restart policy, network, user and memory limit, each mapped to the right key, ready to be committed next to the project it belongs to.

The converter understands quotes and backslash line continuations, accepts both -p 8080:80 and --publish=8080:80, and drops -d and --rm on purpose: in Compose, detaching is decided at docker compose up -d time. Named volumes get a volumes: section at the end of the file, networks other than bridge, host or none get a networks: section, and the YAML comes out without the version: line, which Compose v2 treats as obsolete.

Review before you use it: flags outside the supported list, such as --cap-add, --device or --gpus, are silently ignored, so if your command depends on them, add them to the YAML by hand. Running docker compose config validates the result. The conversion runs entirely in your browser, which matters here: docker run commands often carry database passwords in -e flags, and none of that is sent to any server.

Frequently asked questions

Why is -d missing from the generated file?
Because in Compose, detached mode is not service configuration: you choose it when starting, with docker compose up -d. The converter drops -d and --rm on purpose.
Are all docker run flags supported?
No. The list covers the common ones: name, ports, volumes, env, network, restart, entrypoint, user, workdir, labels, hostname and memory. Anything outside it is ignored and has to be added to the YAML by hand.
Do I need to add a version line to the file?
No. Docker Compose v2 ignores the version field and warns when it is present. The generated file already follows the current format: services at the top, with volumes and networks sections when needed.

Related Tools