Safe Tools

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 :ro makes 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 .env and externalize them by declaring env_file: - .env in your Compose file.

  • Restart Policy(--restartοΌ‰

    docker run --restart unless-stopped β†’ restart: unless-stopped

    * always (restarts on Docker startup even if manually stopped) or unless-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.

docker run

Input

docker-compose.yml

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.