docker run β docker-compose.yml Converter
Instantly convert long and complex docker run commands into IaC-friendly Compose V2 format.
Everything is processed safely in your browser with no data sent to external servers.
πView Options Mapping and Best Practices
Common Options Conversion Mapping
Mapping between common docker run command-line flags and keys in docker-compose.yml.
- Port MappingοΌ
-p,--publishοΌdocker run -p 8080:80βports: - "8080:80"* The left side is the host port, and the right side is the container port. It is safer to wrap them in double quotes so they are parsed as strings.
- Volume MountsοΌ
-v,--volumeοΌdocker run -v ./data:/var/lib/mysqlβvolumes: - "./data:/var/lib/mysql"* The left side is the host directory path, and the right side is the container mount path. Appending
:romakes it Read-Only. - Environment VariablesοΌ
-e,--env,--env-fileοΌdocker run -e MYSQL_ROOT_PASSWORD=secretβenvironment: - "MYSQL_ROOT_PASSWORD=secret"* If there are many secrets, it is recommended to use
--env-file .envand externalize them by declaringenv_file: - .envin your Compose file. - Restart PolicyοΌ
--restartοΌdocker run --restart unless-stoppedβrestart: unless-stopped*
always(restarts on Docker startup even if manually stopped) orunless-stopped(does not restart if explicitly stopped) are commonly used in practice.
Benefits of docker-compose (Compose V2)
Long docker run commands have a high risk of typos and are difficult to share with other developers.
By converting to docker-compose.yml, your infrastructure configuration is expressed as 'Code (IaC)', allowing you to track its history in version control systems like Git. Additionally, it offers the powerful benefit of defining multiple related containers (like a Web server and a DB) in a single file and launching them all at once with just docker compose up -d.
Input
Output
About Security
This tool performs all conversion processing within your browser. Even if the entered command contains secrets, it will never be sent to an external server. Use with peace of mind.