Created
October 5, 2017 13:52
-
-
Save mluis/3b5e0a533721157431075ff7f5c6b7a5 to your computer and use it in GitHub Desktop.
Script to recover Dockerfile from Docker image
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
#!/usr/bin/env sh | |
# (run)$ ./Dockerfile-recovery.sh <IMAGE ID> | |
docker history --no-trunc "$1" | sed -n -e 's,.*/bin/sh -c #(nop) \(MAINTAINER .*[^ ]\) *0 B,\1,p' | head -1 | |
docker inspect --format='{{range $e := .Config.Env}} | |
ENV {{$e}} | |
{{end}}{{range $e,$v := .Config.ExposedPorts}} | |
EXPOSE {{$e}} | |
{{end}}{{range $e,$v := .Config.Volumes}} | |
VOLUME {{$e}} | |
{{end}}{{with .Config.User}}USER {{.}}{{end}} | |
{{with .Config.WorkingDir}}WORKDIR {{.}}{{end}} | |
{{with .Config.Entrypoint}}ENTRYPOINT {{json .}}{{end}} | |
{{with .Config.Cmd}}CMD {{json .}}{{end}} | |
{{with .Config.OnBuild}}ONBUILD {{json .}}{{end}}' "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment