Docker Run to Compose
Paste a docker run command, including line continuations, and copy the Compose service it maps to. Parsing happens in your browser.
docker-compose.yml
services:
web:
image: nginx:1.27-alpine
container_name: web
restart: unless-stopped
ports:
- "8080:80"
volumes:
- "./site:/usr/share/nginx/html:ro"
environment:
- "TZ=Europe/Istanbul"
About this tool
Compose is the readable form of a long run command: every flag becomes a key you can review in a pull request. Ports, volumes, environment variables, labels, capabilities and extra hosts become YAML lists, while --name, --restart, --user and --workdir become single keys.
Named volumes and user-defined networks also need top-level declarations, which the output adds for you — networks as external, since the run command assumed they already exist. Flags with no Compose equivalent are listed above the output instead of being dropped silently.
Frequently asked questions
- Do I still need the version key?
- No. Compose V2 ignores it and warns about it, so it is omitted by default. The option is there for older tooling.
- Why is my network marked external?
- A run command with --network expects the network to exist already. Remove the external flag if you want Compose to create it.
- Are secrets handled?
- Values from -e are copied literally. Move real secrets to an env_file or Docker secrets before committing the result.