Skip to content
My Tiny Utils

Search tools

Type to find a tool, then press Enter to open it.

Docker Run to Compose

Convert docker run commands into docker-compose services. Ports, volumes, env vars, networks, restart policies, and more.

Processed locally in your browser — nothing is uploaded.

Docker Run to Compose

0 characters

compose.yaml

Output appears here…

About Docker Run to Compose

Long docker run commands are hard to maintain. Paste one and get an equivalent docker-compose service definition. Ports, volumes, environment variables, restart policies, networks, resource limits, and many other flags are mapped to their compose keys.

Common uses

  • Migrate a container from an ad-hoc docker run to Compose
  • Turn a README's docker run example into a compose.yaml
  • Understand what a long docker run command actually configures

Example

Input

docker run -d --name web -p 8080:80 -e NODE_ENV=production nginx:alpine

Output

services:
  web:
    image: nginx:alpine
    container_name: web
    ports:
      - "8080:80"
    environment:
      - NODE_ENV=production

Limitations

  • Flags without a compose equivalent are listed as warnings instead of being dropped silently

Frequently asked questions

Does my docker run command leave my browser during conversion?

No. The command is parsed and converted entirely on your device, which matters because docker run commands often carry database passwords and API keys in -e flags — none of it is transmitted or stored.

What happens to docker run flags that Compose doesn't support?

They are listed as warnings under the output instead of being dropped silently. For example, --rm has no compose equivalent (docker compose down removes containers), and -P is flagged so you can list the ports explicitly.

Why is there no detach flag in the generated compose file?

Compose has no equivalent of -d because detaching is decided at start time, not in the file: docker compose up -d runs the same service in the background. The -d in your original command is simply absorbed.

Do named volumes and networks need extra setup in the compose file?

Yes, and the converter adds it: named volumes get a top-level volumes: declaration, and custom networks are declared with external: true on the assumption they already exist. Remove external: true if you want Compose to create the network itself.

Can I convert a podman run command too?

Yes. Commands starting with podman run, docker container run, or a sudo prefix are all accepted, since they share docker run's flag syntax.