Skip to content
migration.tools
docker run to Docker Compose

Docker run to Docker Compose converter

Containers started by hand with long docker run commands are hard to reproduce on a new server. Paste the commands and get a Compose file that captures every flag — the first step to moving a host, or to Kubernetes.

docker run

Docker Compose

The result appears here as soon as there is input.

Processed on this device. Nothing you paste or drop is uploaded.

How to use it

  1. 1Paste your docker run or drop a file onto the input panel.
  2. 2Adjust the options — the result updates as you type.
  3. 3Copy the Docker Compose or download it. Drop several files to convert a batch into one ZIP.

What is converted

Ports, volumes (including --mount syntax), environment variables and env files, networks and aliases, restart policy, user, working directory, entrypoint and command, capabilities, devices, DNS, extra hosts, labels, logging, health checks, ulimits, sysctls, memory and CPU limits, and GPU reservations.

Named volumes and user-defined networks are declared at the top level. Networks are marked external, since a network named on the command line already exists on the host; remove that line to let Compose manage it.

Several commands — separated by new lines or && — become several services in one file. Shell quoting, backslash line continuations and clustered short flags such as -itd are parsed the way a shell would.

Questions

How do I get the docker run command of a running container?

If you no longer have it, docker inspect shows the configuration, and tools such as runlike can reconstruct the command. Paste the result here.

Why is restart: unless-stopped added?

A container started with -d and no --rm is meant to keep running, so the Compose service gets a restart policy that survives reboots. Commands with --rm don't get one.

Guides that use this tool