How to Use Composerize to Convert a docker run Command

Updated

Paste your full docker run command into the input box on composerize.com and the tool generates an equivalent Compose YAML definition you can copy into a docker-compose.yml file. This works for standard docker run invocations that use common flags (ports, volumes, environment variables, restart policies, and so on). Composerize runs entirely in the browser, so JavaScript must be enabled for the page to function.

What you need before starting

  • A working docker run command. The more complete it is, the more accurate the output.
  • A browser with JavaScript enabled. The site is a client-side app; with JavaScript off you only see a "You need to enable JavaScript to run this app" message.
  • Docker and the Compose plugin installed locally if you want to verify the result with docker compose up.

Step-by-step conversion

1. Open the tool and paste your command

Go to composerize.com and paste the entire docker run command into the input field, including the image name and all flags. For example:

docker run -d --name web -p 8080:80 -v /data:/usr/share/nginx/html -e TZ=UTC --restart unless-stopped nginx:latest

2. Read the generated YAML

As you type or paste, Composerize parses the command and produces a Compose service definition in the output area. The example above becomes something like:

version: '3.3'
services:
    web:
        ports:
            - '8080:80'
        volumes:
            - '/data:/usr/share/nginx/html'
        environment:
            - TZ=UTC
        restart: unless-stopped
        image: 'nginx:latest'

Each flag maps to a Compose key: -p → ports, -v → volumes, -e → environment, --restart → restart, and the image becomes image. The --name value becomes the service name.

3. Copy the YAML into a file

Copy the generated block into a file named docker-compose.yml in your project directory. Keep the indentation exactly as produced — YAML is whitespace-sensitive.

4. Verify the service starts

From the directory containing the file, run:

docker compose up

Expected result: Compose pulls the image if needed and starts the service with the same port, volume, and environment settings as your original docker run command. If it starts cleanly, the conversion is correct. Add -d to run it in the background.

Common snags

  • Nothing appears in the output. JavaScript is disabled or blocked. Enable it and reload.
  • A flag is missing from the YAML. Less common or newer docker run flags may not be recognized. Add the missing key manually to the Compose file.
  • YAML indentation errors. Pasting into an editor that re-indents or converts tabs to spaces can break the file. Paste as plain text and check indentation.
  • Multiple containers. Composerize converts one docker run command at a time. For a multi-service stack, convert each command separately and merge the services under a single services: block.
  • version key warnings. Newer Compose versions treat the top-level version field as obsolete. You can remove it; the file still works.

When this approach fits

Use Composerize when you already have a working docker run command and want a quick, readable Compose equivalent — for example, migrating a hand-run container into a reproducible file. If you are authoring a multi-service stack from scratch, or need Compose features with no docker run equivalent (multiple networks, depends_on, profiles), write the Compose file directly instead.