# Docker Run to Compose Converter

URL: https://phishdestroy.io/developer-tools/docker-run-to-compose
Category: General dev
Where it runs: Runs locally (nothing you enter is uploaded)

Turn a docker run one-liner into a docker-compose.yml service with the same image, ports, volumes, environment and restart policy.

## Example input

nginx container

```
docker run -d --name web -p 8080:80 -v ./site:/usr/share/nginx/html:ro -e TZ=UTC --restart unless-stopped nginx:1.27
```

A web service with image nginx:1.27, restart: unless-stopped, port "8080:80", the read-only volume and TZ=UTC under environment.

## FAQ

### Which docker run options are converted?

-p/--publish, -v/--volume, -e/--env, --name, --restart and --network/--net (a network is also declared as external), with a space or = before the value; -d, -i, -t, -it and --rm are skipped. Every other flag, such as -w, --memory, --env-file or the attached form -p8080:80, is dropped without a warning.

### Why is the image name wrong?

The converter takes the last word that is not an option as the image, so a command after the image replaces it: docker run alpine:3.20 echo hello gives image: hello. Remove the trailing command and add it as command: in the YAML yourself.

### Is my command uploaded?

No. Parsing runs in your browser and nothing is sent anywhere, so secrets passed with -e stay on your machine.

## Related tools

- [YAML Formatter](https://phishdestroy.io/developer-tools/yaml-formatter)
- [.env Checker & Sorter](https://phishdestroy.io/developer-tools/env-file-formatter)
- [Random Port Generator](https://phishdestroy.io/developer-tools/random-port-generator)
- [Chmod Calculator](https://phishdestroy.io/developer-tools/chmod-calculator)

All tools: https://phishdestroy.io/developer-tools
