>Fafa Dev Tools

Docker Run to Compose

Convert docker run commands to docker-compose.yml format instantly. Free online Docker Compose converter with YAML output.

0 chars
Output will appear here...

What is Docker Run to Compose?

Docker Compose is a tool for defining multi-container applications in a single YAML file. Converting from docker run commands to docker-compose.yml makes your container setup reproducible, version-controlled, and easier to share. This tool parses docker run flags and generates the equivalent Compose configuration.

How to Use

  1. Paste your docker run command in the input area
  2. The docker-compose.yml output appears instantly
  3. Supported flags: -p, -v, -e, --name, -d, --restart, --network, -w, -u, and more
  4. Download the output as docker-compose.yml

Examples

Simple web server

Inputdocker run -d --name nginx -p 8080:80 -v /html:/usr/share/nginx/html nginx:latest
Outputservices: nginx: image: nginx:latest container_name: nginx ports: - "8080:80" volumes: - /html:/usr/share/nginx/html

With environment and restart

Inputdocker run -d --name app -p 3000:3000 -e NODE_ENV=production --restart unless-stopped node:18
Outputservices: app: image: node:18 container_name: app ports: - "3000:3000" environment: - NODE_ENV=production restart: unless-stopped

Frequently Asked Questions

Which docker run flags are supported?

-d, --name, -p/--publish, -v/--volume, -e/--env, --restart, --network/--net, -w/--workdir, -u/--user, -h/--hostname, --privileged, --add-host. Unsupported flags are ignored.

Does it handle multiple services?

Currently it converts one docker run command at a time. For multiple services, convert each separately and merge the services section manually.

What Compose version does it generate?

It generates Compose v3 format without an explicit version field (as recommended by modern Docker Compose).