How to use the Docker Run to Compose Converter
- 1. Paste the commandMulti-line commands with backslashes and quoted values are fine.
- 2. ConvertEach flag becomes the matching Compose key.
- 3. Review and runCheck skipped flags, then run docker compose up -d.
The sample conversion
The example command starts Nginx with a name, a restart policy, two port mappings, two environment variables, a read-only bind mount, a user network and a memory limit. It becomes one service called web with image: nginx:1.30-alpine, container_name: web, restart: unless-stopped, mem_limit: 512m, the ports "8080:80" and "8443:443", the environment list and the volume. The network appnet is declared at the bottom as external: true, because a docker run command expects the network to exist already.
Anything after the image name, such as a command and its arguments, becomes the command: list.
What is converted and what is not
- Converted: -p, -e, --env-file, -v, --name, --restart, -w, -u, -h, --entrypoint, -m, --cpus, --shm-size, --platform, --network, --label, --cap-add, --add-host, --device, -i, -t, --privileged, --read-only and --init.
- Ignored on purpose: -d and --rm, because Compose manages that itself.
- Listed as not converted: logging, health check, ulimit, DNS, --mount and GPU flags. Add them by hand using the Compose documentation.
The parser follows shell rules for single quotes, double quotes and backslash line breaks, but it does not expand variables like $HOME. Values are written with quotes where YAML would otherwise misread them. Learn the flags themselves in the Docker commands cheat sheet, or build a full stack in the Docker Compose generator.
Frequently asked questions
Why are network names marked external?
With docker run you create the network first. external: true tells Compose to use that existing network. Remove it if you want Compose to create the network.
Does it handle several docker run commands?
One command at a time. Convert each, then paste the services under one services: key.
Is the Docker Run to Compose Converter free?
Yes, the Docker Run to Compose Converter is free. The first time you convert your first command, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.