Skip to content

Instantly share code, notes, and snippets.

@bigsan
Created December 6, 2020 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigsan/0d0dfe7062a97acbdcf238fbdf07c91b to your computer and use it in GitHub Desktop.
Save bigsan/0d0dfe7062a97acbdcf238fbdf07c91b to your computer and use it in GitHub Desktop.
Dockerfile from image history
# https://stackoverflow.com/questions/19104847/how-to-generate-a-dockerfile-from-an-image/50926503#50926503
docker history --no-trunc $argv | tac | tr -s ' ' | cut -d " " -f 5- | sed 's,^/bin/sh -c #(nop) ,,g' | sed 's,^/bin/sh -c,RUN,g' | sed 's, && ,\n & ,g' | sed 's,\s*[0-9]*[\.]*[0-9]*\s*[kMG]*B\s*$,,g' | head -n -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment