Created
November 10, 2022 07:55
-
-
Save saranshkarira/92b5ede79b4d720ad3ef214ddd7e0921 to your computer and use it in GitHub Desktop.
give a docker image name as an argument, get approximate 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 | |
docker history --no-trunc --format "{{.CreatedBy}}" $1 | # extract information from layers | |
tac | # reverse the file | |
sed 's,^\(|3.*\)\?/bin/\(ba\)\?sh -c,RUN,' | # change /bin/(ba)?sh calls to RUN | |
sed 's,^RUN #(nop) *,,' | # remove RUN #(nop) calls for ENV,LABEL... | |
sed 's, *&& *, \\\n \&\& ,g' # pretty print multi command lines following Docker best practices |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment