Docker Run → Compose 変換ツール
docker runコマンドをdocker-compose.yml形式に変換します。ポート、ボリューム、環境変数など30以上のフラグに対応。
バックスラッシュ(\)で続く複数行のコマンドに対応しています。
-d、--rm、-it、--initなどのランタイムフラグは出力に含まれません。
What Is the Docker Run to Compose Converter?
This tool converts a docker run command into a valid docker-compose.yml service definition. Paste any docker run command — with ports, volumes, environment variables, networks, restart policies, and more — and get a ready-to-use Compose file in seconds.
It is especially useful when you have an existing container running from a docker run command and want to migrate it to a Compose-managed stack, or when you find a quick-start command in documentation and need to turn it into a reproducible Compose file.
How to Use the Docker Run to Compose Converter
- Paste your docker run command into the input box. You can include
docker runor just the flags and image name. - Multi-line commands with backslash continuation are supported — paste them as-is.
- Click Convert. The docker-compose.yml output appears below.
- Copy the output and save it as
docker-compose.ymlin your project. - Use the example buttons to try Nginx, PostgreSQL, or Redis presets.
Features
- Supports 30+ docker run flags including ports, volumes, env vars, networks, restart, user, workdir, entrypoint, labels, capabilities, and healthcheck
- Multi-line backslash-continuation commands parsed correctly
- Generates clean docker-compose v2 format (no deprecated version key)
- Auto-detects service name from container name or image name
- 3 built-in examples: Nginx, PostgreSQL, Redis
- One-click copy to clipboard
FAQ
What docker run flags are supported?
The converter supports the most common flags: -p/--publish (ports), -v/--volume (volumes), -e/--env (environment variables), --env-file, --name, --restart, --network, --hostname, -u/--user, -w/--workdir, --entrypoint, --label, --cap-add, --cap-drop, --privileged, --add-host, --dns, --device, --sysctl, --security-opt, --memory, --cpu-shares, --pid, --ipc, and healthcheck flags.
Can I use multi-line docker run commands with backslash continuation?
Yes. You can paste multi-line commands that use backslash-newline continuation (the standard shell convention for splitting long commands across lines). The parser normalizes them automatically.
What version of docker-compose format does this generate?
The output uses the modern top-level services: format without a version: key, which is compatible with Docker Compose v2 and later. This is the recommended format as of Docker Desktop 3.4+.
Does -d / --rm affect the output?
No. Flags like -d (detached), --rm (remove on exit), -it, and --init control container lifecycle at runtime but have no equivalent in docker-compose.yml. They are silently ignored.