A typical detached run
The -d does not carry across, and a restart policy is added
docker run -d --name web -p 8080:80 -e NODE_ENV=production -v /srv/data:/data nginx:alpine
Turn a long docker run into a service definition. Some of what you typed describes how you were running the command rather than what the service is, and that part does not carry across.
Or drop a file anywhere on this panel. Nothing is uploaded: the analysis runs in this tab.
The answer appears here
Paste on the left and press Convert. Nothing leaves this tab.
Nothing else to flag.
No formatting problems, and nothing the rules object to. Worth remembering what that covers: this reads the file you pasted, not the account or cluster it will be applied to.
No finding matches that filter.
Real input you can load into the tool above. Each one shows a different thing going wrong, because that is what the tool is for.
The -d does not carry across, and a restart policy is added
docker run -d --name web -p 8080:80 -e NODE_ENV=production -v /srv/data:/data nginx:alpine
Transient in shell history, permanent in a committed file
docker run -d --name api -e API_KEY=REPLACE_ME myapp:1
Carries across, and converting is a good moment to find out what it actually needed
docker run --privileged --name agent myagent:1
These are the ones that fail silently. The config is accepted, nothing raises an error, and the consequence arrives later.
They describe the invocation. --rm has no equivalent, and stdin_open with tty on an ordinary service is noise that occasionally changes behaviour.
Instead:Drop them. Use docker compose up -d to detach.
docker run defaults to no restart, so a compose service converted verbatim stays down after any exit or reboot.
Instead:Add restart: unless-stopped unless it really is a one-off.
A value that lived in shell history is now committed and shared with everyone who has the repository.
Instead:Use environment: ['API_KEY=${API_KEY}'] with a gitignored .env, or env_file.
--rm, -d and -it are all about the command you typed. None of them belongs in a file that describes what a service is, and one of them has no equivalent at all.
--rm has no compose equivalent. -d is docker compose up -d, a property of how you start the stack. -it maps to stdin_open and tty, which are only meaningful for a service you deliberately attach to, and setting them on a normal service is noise.
docker run defaults to no restart, which is right for a one-off command and wrong for a service in a file somebody will bring up and walk away from. unless-stopped survives a reboot and respects a deliberate stop, which is what most people mean.
Services on the same compose network resolve each other by service name through Docker's embedded DNS, which is what --link approximated. The links key exists in the compose spec and is deprecated there too.
It attaches to something that already exists and is incompatible with the networks key and with links. Compose creates a network per project and puts every service on it, which is why most compose files have no network configuration at all.
-e API_KEY=... was transient in shell history. In a compose file it is committed and shared. Reference it instead, with the value in a gitignored .env, or use env_file.
docker run resolves a relative volume path against your current directory. Compose resolves it against the compose file's directory, so the same string can point somewhere else once converted.