Docker Run to Docker Compose Converter
NEWConvert a docker run command into a compose.yaml file: ports, volumes, env, restart, network, limits and healthchecks, with a list of flags that cannot be mapped.
Runs 100% in your browser — your input is never uploaded or stored on our servers.
compose.yaml
services:
web:
image: nginx:1.27
container_name: web
ports:
- "8080:80"
volumes:
- site-data:/usr/share/nginx/html:ro
environment:
- TZ=UTC
restart: unless-stopped
healthcheck:
test:
- CMD-SHELL
- curl -f http://localhost/ || exit 1
interval: 30s
volumes:
site-data: {}
-d is dropped because Compose runs detached with docker compose up -d. Named volumes and networks are declared at the top level.
Quick Examples
Typical inputs and the results this tool produces.
Overview
A docker run to docker compose converter turns the one-line command from a README or blog post into a compose.yaml you can keep in version control. Paste the command, including backslash line breaks and quoted values, and the matching service appears immediately.
The parser understands short and combined flags such as -dit and -p8080:80, long flags with = or a space, and the image followed by its command. Ports, volumes, mounts, environment variables, env files, restart policy, networks, user, working directory, capabilities, resource limits, healthchecks and logging are mapped to Compose keys.
Flags that Compose cannot express, such as --rm or unknown options, are listed in a warning box instead of being dropped silently. The YAML is written by js-yaml in your browser, so your command is never uploaded.
Why use this tool?
- Turns copy-pasted commands into a reusable compose file
- Handles line continuations, quotes and combined flags
- Unsupported flags are listed, never hidden
- Named volumes and networks declared at the top level
- Runs locally, nothing is uploaded
Features
Flexible parser
Reads \ line breaks, single and double quotes, -dit clusters and --flag=value.
Common flags covered
Ports, volumes, --mount, env, restart, network, user, workdir, capabilities and more.
Healthchecks and limits
--health-* flags, --memory and --cpus become healthcheck, mem_limit and cpus.
Warning list
Flags without a Compose equivalent are reported so nothing disappears quietly.
Valid YAML
Serialised with js-yaml, with quoted ports and a stable key order.
One-click copy
Copy the finished compose.yaml straight into your project.
How to Use
Paste the command
Put your docker run command in the box; multi-line commands with \ are fine.
Read the YAML
The compose.yaml updates as you type, with named volumes and networks declared.
Check the warnings
Review the Not converted list for flags that need manual handling.
Copy and run
Press Copy YAML, save it as compose.yaml and start it with docker compose up -d.