CruxDevCruxDev Tools Prompts
dev Utility • Zero-Server Privacy • 100% Client-Side

Docker Compose Stack Builder

Visually configure multi-service containers (Node, Postgres, Redis, Mongo, Nginx) and export docker-compose.yml.

Overview

Converts in both directions between a docker run command and a Docker Compose service definition. Run-to-compose maps ports, volumes, environment variables, container name, restart policy, and network flags into a version 3.8 services block; compose-to-run condenses a services section back into a single docker run line. Both directions run locally as you type.

How It Works

Choose the direction with the two buttons at the top. For run-to-compose, paste a docker run command; line continuations with backslash are joined first, then the arguments are tokenized with quote awareness, and a compose YAML appears with image, container_name, restart, ports, environment, volumes, and a top-level networks entry marked external for any --network flag. For compose-to-run, paste a compose file containing a services: section and the equivalent docker run -d command is assembled. Copy either output from the results area.

Step-by-Step Usage Guide

  1. Pick Run to Compose or Compose to Run at the top of the tool.
  2. Paste the docker run command or the compose service definition.
  3. Read the output and check the networks section and any dropped flags such as memory limits.
  4. Copy the result into your docker-compose.yml or shell, then validate it with docker compose config.

Technical Specifications & Standards

The run-to-compose parser is a real tokenizer, not a naive split: it handles single and double quoted arguments and joins backslash continuations, then maps each known flag, including both short and long forms such as -p and --publish. Unrecognized flags are skipped rather than erroring, and the first non-flag token becomes the image. Two behaviors to know before trusting the output. First, the --memory or -m flag is captured but never emitted into the YAML, so a memory limit in your run command silently disappears; re-add a mem_limit or deploy.resources key by hand if you need it. Second, the generated networks section marks the network external: true, which is correct only if the network is created outside this compose file; if you expected compose to create it, delete that key. The compose-to-run direction is the weaker parser: it walks the YAML line by line looking for known keys and list items, so it merges every service in the file into one command, ignores indentation-based nesting, and drops keys it does not know, such as depends_on, healthchecks, or build. Multi-service files therefore produce a command for a chimera of their first-seen values. Treat that direction as a starting point for single-service files, not a general converter.

Targeted Use Cases

  • Turning a README's docker run one-liner into a compose service for a local stack.
  • Extracting a container's configuration from a compose file into a runnable command for debugging.
  • Migrating a hand-typed run command into version-controlled infrastructure.
  • Comparing how ports, volumes, and environment maps are spelled in the two formats.

Notes & Gotchas

  • Re-add memory limits by hand; the -m flag is parsed but not written to the YAML output.
  • Do not feed multi-service compose files into the compose-to-run direction; its line-based reader merges services into one command.
  • Check the emitted networks block: it is marked external, which only fits if the network already exists.
  • Validate converted compose output with docker compose config before deploying anything.

Frequently Asked Questions

Does the generated compose file include the version key?

Yes. Output is written under a version: '3.8' header, which older Docker Compose versions expect; current Compose ignores the key, so it is harmless either way.

What happens to the --memory flag from my run command?

It is parsed into an internal variable but never emitted into the YAML, so the limit is lost in conversion. Add a mem_limit or deploy.resources block manually if the limit matters.

Why does the tool mark my network as external?

Any --network or --net flag produces a top-level networks entry with external: true, meaning compose expects the network to exist already. If you want compose to create it, remove the external key.

Can it convert a compose file with several services?

Not correctly. The compose-to-run parser reads the file line by line without nesting, so values from all services are merged into a single command. Convert one service at a time by pasting only that service's block.