Omnikit
DevFilesMoneyAll tools
Ctrl K
Dev toolsFile toolsMoney calculatorsAll tools
HomeDeveloper toolsDocker Run to Compose Converter
EnglishالعربيةবাংলাDeutschEspañolFrançaisPolskiPortuguêsРусский

Docker Run to Compose Converter

dev

Turn docker run commands into a compose.yaml: ports, volumes, networks, health checks

Runs in your browser. Nothing you type is sent anywhere. Checked against sources on 16 Oct 2026.

Each docker run flag has a Compose key. The image stays image, and 5 common flags map directly: -p becomes ports, -e becomes environment, -v becomes volumes, --restart becomes restart and --name becomes container_name, while -it maps to stdin_open and tty. Flags such as -d and --rm have no equivalent, since docker compose up -d runs services in the background.

Next:
  • Nginx Config Generator A commented nginx server block for a reverse proxy, static site, SPA or redirect
  • Dockerfile Linter Check a Dockerfile against 55 hadolint rules: pinned versions, root user, cache and more

How to convert a docker run command to docker compose

1

Paste one or more docker run commands, backslash line breaks and all, or click Try an example.

2

Read the compose.yaml on the right: one service per command, with volumes and networks declared at the bottom.

3

Check the notes for flags that have no Compose equivalent, such as --rm.

4

Click Download to save compose.yaml, then run docker compose up -d in the same folder.

About Docker Run to Compose Converter

A docker run command that works is the best starting point for a compose file, but rewriting 10 flags by hand invites mistakes. Paste the command, or several, and get a compose.yaml with one service each, following the Compose Specification, so it works with docker compose up -d.

docker run compose.yaml
--name web container_name: web
-p 8080:80 ports: ["8080:80"]
-e KEY=value environment: ["KEY=value"]
-v data:/data volumes: plus a top-level data:
--network shop-net networks: plus shop-net: external: true
--restart unless-stopped restart: unless-stopped
-it stdin_open: true, tty: true
--gpus all deploy.resources.reservations.devices

What is understood. More than 70 docker run flags, in every spelling the Docker CLI accepts: --flag value, --flag=value, -p80:80 and grouped short flags such as -it or -dp 3000:3000. Commands broken over lines with \ (bash), ^ (cmd) or ` (PowerShell) are joined, quotes are read as a shell reads them, and $(pwd) in a volume becomes ./, because Compose resolves paths from the compose file's folder.

Several commands at once. Paste a whole setup script: every docker run becomes a service, other commands such as docker network create are skipped, and services sharing an image get distinct names.

Nothing hidden. Flags with no Compose equivalent, like --rm and -d, and any flag the tool does not know are listed under the result instead of disappearing. Ports and environment values are quoted, so no YAML reader takes 22:22 for a number. The file has no version: key, which the Compose Specification made obsolete.

Everything runs in your browser; the commands you paste, which often hold passwords, are never sent anywhere.

Frequently asked questions

How do I convert a docker run command to docker compose?

Give each flag its Compose key under a service: the image as image, -p as ports, -e as environment, -v as volumes, --name as container_name and --restart as restart. Named volumes and custom networks also get a top-level entry. Pasting the command here writes the whole compose.yaml, ready for docker compose up -d.

What do -it and -d become in docker compose?

The -i flag becomes stdin_open: true and -t becomes tty: true, so -it sets both. The -d flag has no key, because docker compose up -d starts every service in the background. To attach to a running service later, use docker compose attach or docker compose exec with the service name.

What happens to --rm in docker compose?

Nothing in the file: Compose services are meant to stay, so there is no key that deletes the container when it stops. For a one-off task, run docker compose run --rm with the service name, which removes that container afterwards. The note under the result says when --rm was left out.

Why is the network marked external: true?

A docker run with --network shop-net uses a network that already exists. Marking it external tells Compose to join that network rather than create its own, so containers started both ways can still talk. To let Compose create and own the network instead, delete the external: true line.

Should ports be quoted in a compose file?

Yes, write ports as strings such as "8080:80". Some YAML readers treat two numbers joined by a colon as a base-60 number, so 22:22 could become 1342 and break an SSH mapping. This tool quotes every port, environment entry and volume string so the file means the same everywhere.

Does docker compose still need the version key?

No. The Compose Specification made the version: key obsolete, and recent versions of docker compose warn when it is present. Files generated here start straight with services:, followed by volumes: and networks: when the commands use named volumes or custom networks.

Sources

  • Docker Docs, docker container run (CLI reference)Every docker run flag and its meaning
  • Docker Docs, Compose file reference: servicesThe Compose key each flag maps to
  • Docker Docs, Compose file reference: volumesNamed volumes declared at the top level
  • Docker Docs, Compose file reference: networksExternal networks
  • POSIX.1-2024 Shell Command Language, 2.2 Quoting (The Open Group)How the pasted command is split into words

Last verified 16 October 2026.

Rates and rules change; check the source before you rely on a figure.

Still stuck? Ask about Docker Run to Compose Converter and anybody who knows can answer. No account needed.

Common uses

  • Docker Compose GeneratorGenerate a docker-compose file from the docker run commands you already use

Same job, other tools: JSON to YAML – Turn JSON into clean, readable YAML for configs · YAML Validator – Check YAML syntax and see the exact line and column of each error.

On the related tools: TSV to JSON – Convert tab-separated values, such as a paste from Excel, into JSON.

Related tools

All developer tools
Base64 Encode & DecodeText and files to Base64 and back, with URL-safe mode and image previewUnix Timestamp ConverterUnix timestamps to dates and dates to timestamps, in any time zoneJSON to TypeScriptGenerate TypeScript interfaces or types from a JSON sampleCSV to JSONConvert CSV to JSON and JSON to CSV, with a table previewYAML to JSONConvert YAML to JSON and JSON to YAML, with anchors resolvedURL Encoder / DecoderPercent-encode or decode text and URLs, and see every part of a linkColor ConverterHEX, RGB, HSL, HWB, OKLCH and CMYK in both directions, with a contrast checkNumber Base ConverterBinary, octal, decimal, hex and any base to 36, exact at any size, with two's complement
Was this tool helpful?
Omnikit

Small jobs, done in your browser. Free, fast and private. Files are never uploaded.

Files

  • Compress Image
  • Image to PDF
  • Merge PDF
  • Compress PDF
  • PDF to Word
  • Word to PDF

Dev

  • JSON Formatter & Validator
  • Base64 Encode & Decode
  • JWT Decoder, Verifier & Encoder
  • Password Generator
  • UUID Generator
  • Unix Timestamp Converter

Money

  • SIP Calculator
  • EMI Calculator
  • GST Calculator
  • FD Calculator
  • PPF Calculator
  • Lumpsum Calculator
EnglishالعربيةবাংলাDeutschEspañolFrançaisPolskiPortuguêsРусский
GuidesQuestionsAboutHow we checkLaw library (beta)PrivacyTermsDisclosureContactMore: Exam practice (UGC NET Paper 1)Runs in your browser. Nothing is uploaded. © 2026 Omnikit (theomnikit.com)