Docker Compose to docker run Converter

Turn a Compose file into the equivalent docker run commands. Some of what Compose was doing for you has no flag, and the first one bites immediately.

Paste below, or drop a file anywhere on this panel

Or drop a file anywhere on this panel. Nothing is uploaded: the analysis runs in this tab.

The answer appears here

Paste on the left and press Convert. Nothing leaves this tab.

Examples

Real input you can load into the tool above. Each one shows a different thing going wrong, because that is what the tool is for.

Two services with a dependency

The network is not automatic, and depends_on has no flag

services:
  web:
    image: nginx:alpine
    ports:
      - "8080:80"
    depends_on:
      db:
        condition: service_healthy
  db:
    image: postgres:16

A relative bind mount

Means a different directory once it is on a command line

services:
  app:
    image: myapp
    volumes:
      - "./data:/data"

Common mistakes

These are the ones that fail silently. The config is accepted, nothing raises an error, and the consequence arrives later.

  1. Running the containers without creating a network

    The default bridge provides no DNS, so a service referring to another by name gets a resolution failure that looks like the other container is down.

    Instead:docker network create, then --network on every container.

  2. Expecting depends_on ordering to carry across

    There is no flag for it. Running the commands in order reproduces the short form, and nothing reproduces a health condition.

    Instead:Run them in order, and make the application retry its connections.

  3. Copying relative volume paths straight across

    Compose resolves them against the compose file; docker run resolves them against your shell's directory, and -v creates the missing path rather than failing.

    Instead:Make them absolute before running the commands.

Compose gives you a network and DNS; docker run gives you neither

Every service in a project joins one network and reaches every other by service name. Run the same containers without that and a reference by name is a DNS failure.

The default bridge has no name resolution at all

So it is not enough to run the containers: they have to share a user-defined network, which you create yourself. That is the first line of the output here, and leaving it out is why a hand-converted stack cannot find its own database.

depends_on has no equivalent

The short form waits for the container to start, which running the commands in order reproduces. The long form with condition: service_healthy waits for a healthcheck to pass, and there is no docker run flag for that at all: you would have to poll docker inspect yourself.

Which is a reminder that depends_on was never a readiness guarantee

The short form is satisfied when the container starts, not when the database accepts connections. The real answer in both worlds is an application that retries its connections.

Relative volume paths change meaning

Compose resolves them against the compose file's directory; docker run resolves them against wherever you are standing. And -v creates a missing host path as an empty root-owned directory rather than failing, so the mount silently points at nothing.

${ } is resolved by Compose, not by your shell

Compose reads .env from the project directory and substitutes before parsing. Your shell knows nothing about that file, so the same expression expands differently, or to nothing.

This direction loses structure

A compose file describes services and relationships. A list of commands describes a sequence, and the relationships end up in a shell script or in somebody's head. Worth doing to understand what Compose was doing, or for a host without it. Not worth doing as a migration.

More docker tools

Docker Container Image Reference Parser Is that a registry or a Docker Hub user? Dockerfile Linter What this image will do to you later docker run to Kubernetes YAML And the flags that have no equivalent Docker Compose to Kubernetes And why depends_on has no equivalent Docker Logging Driver Generator json-file never rotates Dockerfile Non-Root USER Generator Numeric, or Kubernetes rejects it Docker OCI Image Labels Generator One of them actually does something Docker Hub Pull Rate Limit Calculator Counted per IP, not per person Docker Registry Storage Calculator Deleting a tag frees nothing Docker Build Context Analyzer All of it uploads before anything runs Docker Compose Version Migrator version: is obsolete now Docker Compose Network and Port Viewer Everything reaches everything Docker Command Explainer Which flags hand over the host Docker BuildKit Cache Mount Generator apt deletes the cache you just mounted Docker BuildKit Secret Mount Generator ARG is in docker history forever Docker .dockerignore Pattern Tester *.log does not match logs/app.log Docker Image Manifest Viewer unknown/unknown is not broken Docker Image Config Viewer Anyone who can pull can read your Env Docker Registry Token Decoder Check the scope before the credentials Docker HEALTHCHECK Generator Docker does nothing when it fails Docker Network Subnet Calculator 31 networks, then it stops Docker History Analyzer The rm did not save anything Docker Run to Compose Converter Some flags have no equivalent Docker CMD and ENTRYPOINT Tester Why docker stop takes ten seconds Docker Port Mapping Tester -p reaches past your firewall Docker -v to --mount Converter -v invents missing directories Docker Restart Policy Simulator The backoff resets after ten seconds Docker Exit Code Explainer 137 is two different problems Docker CPU Limit Converter --cpu-shares limits nothing Docker Memory Limit Calculator -m 512m allows a gigabyte Docker Compose Interpolation Tester An unset variable is an empty string Docker Environment Variable Precedence Tester Your shell does not reach the container Docker Compose Override Merge Previewer An override can add a port, never remove one Dockerfile Multi-Stage Build Analyzer Which stages reach the image Dockerignore Validator It is not .gitignore

Elsewhere on the site