How It Works Under the Hood
The CLI tokenizer handles POSIX shell line continuations (`\`), quoted values, and combined short flags (`-dit`), mapping `-p`, `-v`, `-e`, `--name`, `--restart`, `--network`, and trailing image/command arguments into structured YAML. Reverse parsing extracts service keys from indentation-based `services:` YAML sections.
Step-by-Step Instructions
Pick conversion direction (`docker run -> compose.yaml` or `compose.yaml -> docker run`).
Paste your container CLI command or Compose YAML service specification.
Inspect warnings for unsupported custom daemon flags if any appear.
Copy the output or download `compose.yaml` / `docker-run.sh` directly.
Key Features & Performance
- Handles multi-line `\` shell continuations and quoted arguments cleanly
- Maps `-p` ports, `-v` volumes, `-e` environment variables, `--restart`, `--network`, and command overrides
- Produces modern Compose v2 spec without deprecated top-level `version:` boilerplate
- Supports reverse translation from `compose.yaml` services back into individual `docker run` CLI commands
- Offline execution keeps private registry URLs and database environment vars private
Methodology, Formulas & Technical Standards
Shell tokenization implements state-machine quote handling (`'`, `"`, escaping) before flag-pair resolution (`--flag=val` and `--flag val`). YAML emission escapes colons and shell characters consistently and generates valid named/anonymous service blocks.
Common Real-World Use Cases
- Migrating one-off `docker run` commands from documentation into version-controlled `compose.yaml` stacks
- Converting complex multi-container Compose files back into standalone `docker run` commands for CI runners
- Quickly reviewing exposed ports and mounted host paths in copied container snippets
- Onboarding teammates with reproducible local Postgres/Redis Compose templates
Worked Examples & Edge Cases
Redis CLI -> compose.yaml
docker run -d --name cache -p 6379:6379 -v redis_data:/data redis:7-alpine
services:
cache:
image: redis:7-alpine
ports:
- "6379:6379" Automatically infers the Compose service key from `--name` or image name.
Compose -> Standalone CLI
services:
postgres:
image: postgres:16-alpine
ports: ["5432:5432"] docker run -d -p "5432:5432" postgres:16-alpine
Handy when debugging single containers outside Compose.
Limitations, Scope & Accuracy Notes
- • Advanced Compose keys (`deploy.resources`, `depends_on` healthcheck conditions, complex YAML anchors) are omitted or flagged with warnings during reverse CLI translation.
- • Verify sensitive `-e` passwords before committing generated YAML files to Git.
Local Browser Processing & Privacy
Traditional web converters upload your documents, snippets, or media files to remote servers. Docker Run ↔ Compose YAML Converter runs inside your browser tab:
Your input text and files are processed locally without uploading payloads to a processing server.
Microdeck does not log or store the files or inputs you paste into tool workspaces (normal static hosting/CDN requests still load page assets).
Working outputs stay in your browser tab and are released when you reset the tool or close the tab.
Frequently Asked Questions
Why does the generated `compose.yaml` omit the `version:` key?
Docker Compose v2 deprecated the top-level `version:` property; modern Compose files start directly with `services:`.
Are multi-line `docker run` commands with `\` supported?
Yes. Escaped line breaks and single/double-quoted flag arguments are normalized automatically before parsing.
Can a `compose.yaml` with multiple services convert back to CLI?
Yes. Each service under `services:` emits its own standalone `docker run` command separated by blank lines.
Is my private image URL or env secret logged?
No. Translation runs synchronously inside browser JavaScript with zero server calls.
Explore Related Micro-Tools
.env Diff, Formatter & Secret Sanitizer
Compare environment files side-by-side, sort keys alphabetically, and scrub secrets into .env.example
YAML, JSON & TOML 3-Way Converter
Convert, format, and validate YAML 1.2, JSON, and TOML 1.0 safely without network calls
Stack .gitignore Builder & Deduplicator
Compose clean deduplicated .gitignore templates across Node, Astro, Python, Rust, Go, macOS, VS Code & Docker