Skip to content

Instantly share code, notes, and snippets.

@3lpsy
Last active September 16, 2020 02:14
Show Gist options
  • Save 3lpsy/299d8f47c3775f5824cbabdc383d0f35 to your computer and use it in GitHub Desktop.
Save 3lpsy/299d8f47c3775f5824cbabdc383d0f35 to your computer and use it in GitHub Desktop.
Restore docker file from image
#!/bin/bash
# Stolen: https://stackoverflow.com/questions/19104847/how-to-generate-a-dockerfile-from-an-image
DOCKER_IMAGE="$1"
sudo docker history --no-trunc ${DOCKER_IMAGE} | 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