See this docker container?
Set up by hand a while ago. Nobody wrote down how.
$ docker psCONTAINER ID IMAGE STATUS NAMES
9deebcc830db nginx:1.27-alpine Up 7 months (healthy) shop-webI wish I could run another one just like it…
But look at all these settings! 😱 How can I turn this into a docker run command?
$ docker inspect shop-web[ { "Id": "9deebcc830dbd90656f94f9e2f01724878e8be1013f9c75d20c0e08c82d9b5db", "Created": "2026-04-02T09:14:51.120384733Z", "Path": "/docker-entrypoint.sh", … "HostConfig": { "Binds": [ "shop-data:/usr/share/nginx/html", "shop-cache:/var/cache/nginx" ], "ContainerIDFile": "", "LogConfig": { "Type": "local", "Config": { "max-size": "10m" } }, "NetworkMode": "shop-net", "PortBindings": { "80/tcp": [ { "HostIp": "", "HostPort": "8080" } ] }, "RestartPolicy": { "Name": "unless-stopped", "MaximumRetryCount": 0 }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "ConsoleSize": [ 0, 0 ], "CapAdd": null, "CapDrop": null, "CgroupnsMode": "private", "Dns": null, "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "GroupAdd": null, "IpcMode": "private", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 67108864, "Runtime": "runc", "Isolation": "", "CpuShares": 0, "Memory": 268435456, "NanoCpus": 1500000000, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": [], "BlkioDeviceReadBps": [], "BlkioDeviceWriteBps": [], "BlkioDeviceReadIOps": [], "BlkioDeviceWriteIOps": [], "CpuPeriod": 0, "CpuQuota": 0, "CpuRealtimePeriod": 0, "CpuRealtimeRuntime": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": [], "DeviceCgroupRules": null, "DeviceRequests": null, "MemoryReservation": 0, "MemorySwap": 536870912, "MemorySwappiness": null, "OomKillDisable": null, "PidsLimit": null,That is what runlike does.
Give it a container and it prints the docker run command that recreates it, every pesky option included: ports, volumes, networks, limits, labels, the lot.
$ runlike -p shop-webdocker run \ --name=shop-web \ --env=TZ=Europe/Berlin \ --env=NGINX_HOST=shop.example.com \ --detach \ --network=shop-net \ --network-alias=web \ --publish=8080:80 \ --volume=shop-data:/usr/share/nginx/html \ --volume=shop-cache:/var/cache/nginx \ --cpus=1.5 \ --memory=256m \ --restart=unless-stopped \ --log-driver=local \ --log-opt=max-size=10m \ '--health-cmd=wget -qO- http://localhost/ || exit 1' \ --health-interval=30s \ --label=app=shop \ --label=managed-by=ansible \ nginx:1.27-alpine$ Download
One static binary, nothing to install. runlike talks to Docker through your
docker command, so contexts and DOCKER_HOST work as usual, and the Docker CLI must be installed.
It looks like you are on .
-
macOSApple Silicon
runlike-darwin-arm64 -
Linuxx86-64
runlike-linux-amd64 -
LinuxARM64
runlike-linux-arm64 -
Windowsx64
runlike-windows-amd64.exe -
WindowsARM64
runlike-windows-arm64.exe
All releases · SHA256SUMS · Intel Mac or another system: use Go or the Docker image below.
Download, rename to runlike, make it executable, put it on your PATH. On macOS and Linux:
curl -fsSLo runlike https://github.com/lavie/runlike/releases/latest/download/runlike-linux-amd64
chmod +x runlike && sudo mv runlike /usr/local/bin/The macOS binary is signed and notarized by Apple.
On macOS (Apple Silicon) and Linux, from the tap lavie/homebrew-tap. brew upgrade keeps it current.
brew install lavie/tap/runlikeGo 1.24 or later. Lands in $(go env GOPATH)/bin.
go install github.com/lavie/runlike/v2/cmd/runlike@latestassaflavie/runlike ships runlike with the Docker CLI. Mount the socket:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie/runlike CONTAINEROr make it an alias:
alias runlike="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie/runlike"Usage
Point it at a container. Read the line, edit it, run it.
runlike web- Prints the
docker runcommand for the containerweb, on one line, every value quoted for the shell. eval "$(runlike --no-name web)"- Run the copy. Why
eval? A bare$(runlike web)makes the shell split the output on spaces and keep the quotes as text, soGREETING=hello worldreaches Docker as two broken arguments.evalparses the line the way it would if you typed it. runlike -p web- Pretty. One option per line, as in the example above. Easier to read, and to delete the one line you want to change.
docker inspect web | runlike --stdin- From saved JSON. No daemon needed: paste inspect output from a ticket, a backup or another machine. Without image data runlike prints a bit more than it has to (see caveats).
--no-name- Leaves out
--name, so the copy does not collide with the original. Use it whenever the original is still running. --no-labelsor-l- Leaves out
--label. Handy for containers that Compose or an orchestrator covered in metadata. --use-volume-id- Keeps the generated names of anonymous volumes, so the copy reuses their data instead of starting with fresh ones.
--shell powershellor--shell cmd- Quotes for PowerShell 7.3 or later, or for
cmd.exe, instead of a POSIX shell. Paste the line; noevalthere.
Caveats
A few things can't be copied exactly: Docker doesn't keep them, or docker run has no flag for them. Here is what to watch for.
- Seccomp profiles are stored as JSON, not as the file name you passed. runlike prints the JSON; save it to a file and pass that instead.
- Exec-form health checks from a Dockerfile (
HEALTHCHECK CMD ["curl", …]) have nodocker runflag. They come back as--health-cmd, which runs through/bin/sh. -e NAMEwithout a value copiesNAMEfrom your environment when you run the line, which may differ from the original's empty value.- The same variable set twice: only the last counts; runlike prints both.
- MAC addresses on further networks: Docker reports a pinned MAC only for the first network. On others, runlike prints none, so a copy never duplicates a random one. If you pinned it, add
mac-address=to that--networkyourself. - Upper case on extra networks is lowercased by
docker runitself in the long--network=name=…form. --stdinmode has no image and no daemon to ask: values the image already sets are printed too,container:targets come out as IDs, and only Docker's built-in defaults are left out.- Hyper-V isolation on Windows is tested on saved inspect data only.
- Client-only options such as
--pull,--quiet,--detach-keysand--sig-proxyare never stored by Docker, so no tool can read them back.
The full table of all 103 options, with what each one does in runlike: docs/options.md.
Contributing
runlike lives at github.com/lavie/runlike.
Found a container it gets wrong? Open an issue with the
docker inspect output (minus secrets). Pull requests are welcome; every option is
checked by a round trip against a real Docker daemon, so bring a test.
runlike 2.0 is written and maintained by AI coding agents; a human maintainer approves every release.