DevTools Logo

Docker Run to Compose Converter

Docker Run to Compose Converter

Turn a docker run command into a docker-compose.yml service definition

Input & Settings

2 spaces

About this tool

This tool parses a `docker run` command and emits an equivalent `docker-compose.yml` service definition. It maps the common flags — image, container name, published ports, volumes, environment variables, networks, restart policy, workdir, user, entrypoint, labels and command — to their Compose equivalents. The companion Docker Compose Builder (already in DevTools) goes the other direction visually. Use this when migrating one-off `docker run` invocations into a versioned Compose file. Parsing is client-side; no command is executed.

Examples & Use Cases

Web server with port mapping

# docker run command
docker run -d --name web -p 8080:80 nginx:latest

# docker-compose.yml
services:
  web:
    image: nginx:latest
    container_name: web
    ports:
      - "8080:80"

The container name becomes the service key; -p host:container maps to the ports list.

Database with env + volume

# docker run command
docker run -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=app -v pgdata:/var/lib/postgresql/data postgres:15

# docker-compose.yml
services:
  postgres:
    image: postgres:15
    environment:
      POSTGRES_PASSWORD: secret
      POSTGRES_DB: app
    volumes:
      - pgdata:/var/lib/postgresql/data

Environment flags become a key/value map; named volumes map to the volumes list.

Restart policy + network

# docker run command
docker run --restart unless-stopped --network mynet redis:7

# docker-compose.yml
services:
  redis:
    image: redis:7
    networks:
      - mynet
    restart: unless-stopped

--restart maps to the restart field; --network maps to the networks list.

    .env Secret Safety Linter

    Validate .env syntax and spot likely leaked credentials or placeholder secrets.

    .htaccess Generator

    Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth

    2D Fluid Dynamics & Particle Physics Sandbox

    A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.

    AI Function Calling Schema Generator

    Generate function calling JSON schemas from TypeScript interfaces

    Algorithm Arena & Data Structure Visualizer

    Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.

    Ansible Playbook Generator

    Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML