-
-
Save maprangzth/5125d4bf9cd7c4c59f2a59b12dd932b0 to your computer and use it in GitHub Desktop.
# การแสดงประวัติการสร้าง Docker image ด้วยคำสั่ง docker history
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 | |
# MrChoke | |
# Ref: https://docs.docker.com/engine/reference/commandline/history/ | |
# Ref: https://stackoverflow.com/questions/19104847/how-to-generate-a-dockerfile-from-an-image | |
if [ $# -eq 0 ]; then | |
echo "No docker image provided." | |
echo -e "Example:\n" | |
echo -e "$0 nginx:latest\n" | |
exit 1 | |
fi | |
docker history \ | |
--no-trunc \ | |
--format "{{.CreatedBy}}" \ | |
$1 \ | |
| tac \ | |
| awk ' | |
{ | |
gsub(/^\/bin\/sh \-c #\(nop\) /,""); | |
gsub(/^\/bin\/sh \-c /,"RUN "); | |
gsub(/\/bin\/sh \-c /,""); | |
gsub(/^[ \t]+|[ \t]+$/,""); | |
gsub(/ && /,"\\\n & ") | |
}1' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment