thbkrkr
4/24/2019 - 11:48 AM

Reverse Docker image

Reverse Docker image

#!/bin/sh

docker history --no-trunc "$1" \
        | 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]*[kMG]*B\s*$,,g' \
        | head -n -1