Created
September 2, 2017 15:55
-
-
Save eschen42/04dfafc63d14f196389fc5c5b262465b to your computer and use it in GitHub Desktop.
Dump a Docker image as the skeleton of a DockerFile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# emit skeletion of DockerFile for the image given by the first (and only) argument | |
echo "# Here is a skeleton DockerFile for docker image '$1'" | |
docker history --no-trunc $1 \ | |
| sed '1 d; s/.* ago [ ]*/RUN /; s/[ ][ ]*[0-9.][0-9.]*[kMG]*B[ ][ ]*$//; s/^RUN .bin.sh -c #.nop. [ ]*//' \ | |
| tac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
quick start
introduction
Sometimes I want to see what's in a Docker image, e.g.,
My intent here is not to produce a runnable DockerFile but rather (without much effort) to emit something that I can read easily.
I searched for "create dockerfile from image" and found the dockerfile-from-image repository, but I couldn't get the docker image to run.
So, I wrote this script that leverages docker history, sed, and tac; it shares many of the limitations of the tool linked above