Docker Compose to docker run converter
Paste a Compose file, pick a service, and get the docker run command that starts the same container. Your file stays in this browser.
Paste the text, or choose a file from your computer. Up to 512 KiB.
0 of 512 KiB
Need a server to run this file?
ANAROQ is in development and doesn't sell servers. These are some options for renting a server, in no particular order.
- View plans at Contabo (opens in a new tab)
- View plans at DigitalOcean (opens in a new tab)
- View plans at Hostinger (opens in a new tab)
- View plans at Vultr (opens in a new tab)
Regular links, not affiliate links. ANAROQ earns nothing from them. Providers are not ranked. How ANAROQ may earn from links
What it does
It reads a Compose file with the same safe parser as the Compose Analyzer and writes one service as a docker run command, one option per line: ports in short or long syntax, volumes and mounts, environment, networks with aliases and fixed addresses, health check, limits from deploy.resources, logging and more.
How it works
- The file is parsed with size, depth and alias limits; no YAML tag or include is followed.
- Every value is quoted for a POSIX shell. Compose interpolation such as ${DB_PASSWORD:?} becomes the same shell expansion, so the command reads the variable from your shell, and a literal $$ stays a literal $.
- Attributes docker run has no option for (depends_on, build, profiles, most of deploy) are listed as notes, with their line in your file.
- Your file is also checked by the Compose Analyzer, the same rules as /tools/compose-analyzer.
Example
A service with a secret from .env, converted:
services:
db:
image: postgres:17
restart: unless-stopped
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set it in .env}
ports:
- "127.0.0.1:5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata: {}
docker run -d \
--restart unless-stopped \
-e POSTGRES_PASSWORD="${POSTGRES_PASSWORD:?Set it in .env}" \
-p 127.0.0.1:5432:5432 \
-v pgdata:/var/lib/postgresql/data \
postgres:17
Limits
- One service per command. A file with several services gets a service picker; links between them (depends_on, service names) do not carry over.
- Compose names volumes and networks after the project (<project>_data); the command uses the plain name unless the file sets name:. Each case is listed.
- docker run does not read .env: export the variables first. Nothing is run here.
- build: is not converted: build and tag the image first.
Sources
Related
Next step
A free public tool by ANAROQ, a company building compute infrastructure. What ANAROQ is building