Reverse Engineering Docker Image

How to get Dockerfile from existing Docker image

Simple commands that allows you to create Docker image file from existing Docker image.

For ease of use let’s create alias for reverse engineering command:

Preparation:

alias dfimage="docker run -v /var/run/docker.sock:/var/run/docker.sock --rm alpine/dfimage"

Reverse engineering:

Now we can use alias like that:

dfimage -sV=1.40 hello-world

Result:

Information about structure Dockerfile of existing image.

Analyzing hello-world
Docker Version: 18.06.1-ce
GraphDriver: overlay2
Environment Variables
|PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Image user
|User is root

Potential secrets:
Dockerfile:
CMD ["/hello"]