Skip to content

Instantly share code, notes, and snippets.

@afreisinger
Last active January 30, 2023 10:45
Show Gist options
  • Save afreisinger/c3a889140a5be5f53c7b5110b1ff5a08 to your computer and use it in GitHub Desktop.
Save afreisinger/c3a889140a5be5f53c7b5110b1ff5a08 to your computer and use it in GitHub Desktop.
Generate a Dockerfile from an image
#!/bin/bash
#https://stackoverflow.com/questions/19104847/how-to-generate-a-dockerfile-from-an-image
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