⚡
usefultools.dev
🐳

Docker Run to Docker Compose Converter

NOVO

Convert a docker run command into a compose.yaml file: ports, volumes, env, restart, network, limits and healthchecks, with a list of flags that cannot be mapped.

Funciona 100% no seu navegador — o que você insere nunca é enviado nem armazenado nos nossos servidores.

Esta ferramenta ainda não está totalmente traduzida, por isso parte do texto continua em inglês. A ferramenta funciona da mesma forma em todos os idiomas.

compose.yaml

services:
  web:
    image: nginx:1.27
    container_name: web
    ports:
      - "8080:80"
    volumes:
      - site-data:/usr/share/nginx/html:ro
    environment:
      - TZ=UTC
    restart: unless-stopped
    healthcheck:
      test:
        - CMD-SHELL
        - curl -f http://localhost/ || exit 1
      interval: 30s
volumes:
  site-data: {}

-d is dropped because Compose runs detached with docker compose up -d. Named volumes and networks are declared at the top level.

⚡

Exemplos rápidos

Entradas típicas e os resultados que esta ferramenta gera.

Basic
docker run -d --name web -p 8080:80 nginx:1.27
Service web with image nginx:1.27, container_name web and ports "8080:80"
docker run -e TZ=UTC --restart unless-stopped redis:7
Service redis with environment - TZ=UTC and restart: unless-stopped
Named volume
docker run -v pgdata:/var/lib/postgresql/data postgres:16
volumes - pgdata:/var/lib/postgresql/data, plus a top-level volumes entry pgdata: {}
Warning
docker run --rm -it alpine sh
tty: true, stdin_open: true, command: sh; warning that --rm has no compose equivalent
📖

Visão geral

A docker run to docker compose converter turns the one-line command from a README or blog post into a compose.yaml you can keep in version control. Paste the command, including backslash line breaks and quoted values, and the matching service appears immediately.

The parser understands short and combined flags such as -dit and -p8080:80, long flags with = or a space, and the image followed by its command. Ports, volumes, mounts, environment variables, env files, restart policy, networks, user, working directory, capabilities, resource limits, healthchecks and logging are mapped to Compose keys.

Flags that Compose cannot express, such as --rm or unknown options, are listed in a warning box instead of being dropped silently. The YAML is written by js-yaml in your browser, so your command is never uploaded.

Por que usar esta ferramenta?

  • Turns copy-pasted commands into a reusable compose file
  • Handles line continuations, quotes and combined flags
  • Unsupported flags are listed, never hidden
  • Named volumes and networks declared at the top level
  • Runs locally, nothing is uploaded
⭐

Recursos

🧩

Flexible parser

Reads \ line breaks, single and double quotes, -dit clusters and --flag=value.

🔌

Common flags covered

Ports, volumes, --mount, env, restart, network, user, workdir, capabilities and more.

🩺

Healthchecks and limits

--health-* flags, --memory and --cpus become healthcheck, mem_limit and cpus.

⚠️

Warning list

Flags without a Compose equivalent are reported so nothing disappears quietly.

📝

Valid YAML

Serialised with js-yaml, with quoted ports and a stable key order.

📋

One-click copy

Copy the finished compose.yaml straight into your project.

🛠️

Como usar

1

Paste the command

Put your docker run command in the box; multi-line commands with \ are fine.

2

Read the YAML

The compose.yaml updates as you type, with named volumes and networks declared.

3

Check the warnings

Review the Not converted list for flags that need manual handling.

4

Copy and run

Press Copy YAML, save it as compose.yaml and start it with docker compose up -d.

🤔

Perguntas frequentes