Retrieve Docker Run Commands & Export Dockerfiles with runlike and whaler
This guide introduces two handy Docker utilities—runlike for instantly printing a container's original run command and whaler for extracting a Dockerfile from an image—detailing installation via pip or Docker, usage examples, alias setup, and practical output considerations.
Docker users often need to recall the exact command used to start a container or to reconstruct the Dockerfile that built an image. Two command‑line tools, runlike and whaler , simplify these tasks.
1. Retrieve the original Docker run command with runlike
runlikeprints the full docker run command that was used to launch a given container. It can be installed via pip or run directly as a Docker container, avoiding any local installation.
# pip installation
pip install runlike
# Docker‑based usage (no install needed)
alias runlike="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie/runlike"After setting up the alias, invoke the tool with the container name: runlike my_container_name The command outputs the complete docker run line, including all flags, environment variables, volumes, and ports, making it easy to recreate the container on another host.
2. Export a Dockerfile from an image with whaler
When the original Dockerfile is unavailable—such as for third‑party images or long‑forgotten builds— whaler can generate a best‑effort Dockerfile from the image layers. Like runlike, it can be used without installation by running a Docker container.
# Alias for convenient use
alias whaler="docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock:ro pegleg/whaler"Run the alias with the target image name to produce the Dockerfile:
whaler pegleg/whalerThe generated Dockerfile reflects the image’s build steps, though multi‑stage builds may omit intermediate stages (e.g., the --from=builder stage). You can try different images to see more natural output.
Both tools are lightweight, require only Docker access, and help streamline container debugging and documentation workflows.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
