runlike

See this docker container?

Set up by hand a while ago. Nobody wrote down how.

zsh
$ docker psCONTAINER ID   IMAGE               STATUS                   NAMES
9deebcc830db   nginx:1.27-alpine   Up 7 months (healthy)    shop-web

I 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?

zsh
$ 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.

Download How to use it

zsh
$ 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.

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/runlike

Go 1.24 or later. Lands in $(go env GOPATH)/bin.

go install github.com/lavie/runlike/v2/cmd/runlike@latest

assaflavie/runlike ships runlike with the Docker CLI. Mount the socket:

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie/runlike CONTAINER

Or 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 run command for the container web, 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, so GREETING=hello world reaches Docker as two broken arguments. eval parses 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-labels or -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 powershell or --shell cmd
Quotes for PowerShell 7.3 or later, or for cmd.exe, instead of a POSIX shell. Paste the line; no eval there.

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.

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.