Skip to content

DevOps

Docker Run to Compose

Convert docker run commands into Docker Compose YAML.

Loading tool…

Find this tool in

About this tool

What is Docker Run to Compose?

Translate a supported docker run command into a Compose starting point while retaining the meaning of ports, environment values and volumes. Inspect every generated field before using it. The converter does not launch containers or infer services that were absent from the original command, such as a database the application expects elsewhere.

A worked example

Keep the published host port distinct from the container port

Example input

docker run --name web -p 8080:80 nginx:stable

Expected result

ports:
  - "8080:80"

The fragment preserves host port 8080 forwarding to container port 80. It is an excerpt from the generated service definition, not a whole Compose file. Review any warnings about unsupported flags, then check the complete YAML with your Compose tooling. The image tag in the sample is illustrative and is not a recommendation to deploy an unreviewed mutable tag.

Common mistakes and limits

  • A volume mount can expose or replace important host paths. Review mount sources and destinations before running a converted command.
  • Shell expansion and quoting can change what a command means. Supply a literal command and inspect values rather than expecting the browser to run your shell.

Features

What you can do

  • Convert single-line and multiline docker run commands.
  • Extract Docker images and container names.
  • Convert published TCP and UDP ports.
  • Convert bind mounts and named volumes.
  • Generate top-level named volume declarations.
  • Convert environment variables and labels.
  • Support restart policies, working directories and entrypoints.
  • Support users, hostnames, networks and privileged mode.
  • Preserve command arguments following the image.
  • Report unsupported or non-equivalent options.
  • Copy or download the generated compose.yaml file.
  • Parse every command locally inside your browser.

Frequently asked questions

Questions about Docker Run to Compose

Does the converter execute the Docker command?

No. The command is only parsed locally and is never executed.

Which docker run options are supported?

The converter supports common options including name, restart, ports, volumes, environment variables, labels, working directory, entrypoint, hostname, user, network and privileged mode.

Are all docker run options equivalent to Compose?

No. Some runtime flags do not map directly to a persistent Compose service. These options are shown as warnings for manual review.

Are named volumes declared automatically?

Yes. Named volumes used by the service are also added to the top-level volumes section.

Are environment values uploaded?

No. Docker commands and environment values remain inside your browser.

Should I review the generated YAML?

Yes. Always review generated Compose configuration before using it in development or production.

Related tools