Inspect Any Docker Container's Original Run Command with runlike
When you inherit a server with running containers, the first question is always: how was this started? docker ps shows the image and uptime, but not the flags, environment variables, volume mounts, or network settings. docker inspect gives you everything in JSON — it’s complete but hard to read. runlike sits in the middle: it reads a container’s configuration and prints the equivalent docker run command.
Adding as an Alias
# ~/.bashrc or ~/.zshrc
alias runlike="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie/runlike"
# Now just use the container name
runlike my-web-app
runlike postgres-db
runlike redis-cache
The Problem: Container Drift
%%{ init: { 'look': 'handDrawn' } }%%
graph TD
A[Original deployment<br/>docker run...<br/>--env VAR=value<br/>--mount /data] --> B[Container runs<br/>for 6 months]
B --> C[Hotfix applied<br/>env changed in code]
C --> D[Another change<br/>volume path updated]
D --> E[Original run command<br/>completely undocumented]
F[New engineer<br/>onboards] --> G[Wants to redeploy<br/>How was this started?]
G --> H[docker ps → only image name]
H --> I[docker inspect → JSON, hard to parse]
I --> J[runlike → docker run command]
Without the original run command, you can’t rebuild the container with the same settings. runlike reconstructs it from the container’s stored configuration.
Using runlike
# Basic usage — pass the container name
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
assaflavie/runlike YOUR-CONTAINER
# Example output:
# docker run --rm \
# --name=YOUR-CONTAINER \
# -p 80:80 \
# -p 443:443 \
# -e NODE_ENV=production \
# -v /data/app:/var/www/html \
# --network=frontend \
# nginx:alpine
The output is a complete docker run command that you can copy, modify, and run on any Docker host.
When This Is Essential
1. Documenting how a service was launched
# Get the run command and save it to a startup script
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
assaflavie/runlike nginx-proxy >> start-nginx.sh
# Make it executable
chmod +x start-nginx.sh
# Commit to the repo alongside docker-compose files
git add start-nginx.sh
2. Rebuilding after a crash
When a container fails and can’t restart (volume mount disappeared, port conflict), you need to know the exact flags to bring it back:
# Get the command, fix the issue, re-run
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
assaflavie/runlike broken-container
# Fix the problem (e.g., recreate volume)
docker volume create data-volume
# Re-run with corrected flags
docker run -d \
--name=broken-container \
-v data-volume:/data \
-p 8080:8080 \
my-image:tag
3. Comparing running config to docker-compose
# Get what container is actually running with
runlike running-app > actual-run.sh
# Compare to what's in docker-compose.yml
diff actual-run.sh docker-compose-derived-run.sh
Any drift between what docker-compose defines and what’s actually running becomes visible.
What runlike Reconstructs
%%{ init: { 'look': 'handDrawn' } }%%
graph LR
A[Container config<br/>from Docker API] --> B[runlike<br/>parser]
B --> C[docker run flags]
C --> D[-p port mappings]
C --> E[-e environment vars]
C --> F[-v volume mounts]
C --> G[--network]
C --> H[--restart policy]
C --> I[--user]
C --> J[--memory limits]
C --> K[--env-file]
runlike handles: port mappings (-p), environment variables (-e), volume mounts (-v), networks, restart policies, user/group, memory/CPU limits, and env files.
Limitations
- Doesn’t capture secrets — environment variables that were set from
--env-fileare captured, but dynamically resolved variables (like those from a secrets manager) show as the resolved value, not the reference - Single container only — doesn’t work with Docker Swarm or Kubernetes (use
kubectl get pod -o yamlfor that) - Docker Socket required — the container must be accessible via the local Docker socket
For day-to-day operations, runlike is a quick bridge between “what’s running” and “how do I recreate it.”