When we use Docker it's very easy push and pull image in a public repository in our https://hub.docker.com
but this repository it's free only for public image(only one can be private).
Currently it's possible to execute a reverse engineering of a public image in repository and read the source code of project ?
In order to help reverse engineer this image into a Dockerfile, we will need to parse everything and reformat it into a form that is readable. Please note that for the purposes of this article, the following Python 3 code has been made available and can be obtained from the Dedockify repository on GitHub.
Whatever the reason, if you wish to recover a Dockerfile from an image, there are options. Docker images aren't a black box. Often, you can retrieve most of the information you need to reconstruct a Dockerfile.
A Docker image is a tar archive that contains a top level repositories files, and then a number of layers stored as directories containing a json file with some metadata about the layer and a tar file named layer.tar with the layer content.
If you want to get the image on your other machine and don't want to build it again then the ideal way is push the docker image created on your Ubuntu server to docker hub repository. Then you can simply do the docker pull to pull the image at any machine.
With some additional changes to the recovered Dockerfile syntax, Dedockify can potentially be updated to completely automate the reverse engineering of a Docker image into a functional Dockerfile in most cases.
Note that the script only works against images that exist in your local image repository (the stuff you see when you type docker images). If you want to generate a Dockerfile for an image that doesn't exist in your local repo you'll first need to docker pull it.
The Dive tool examines each layer of a Docker image. Let’s create a simple, easy-to-follow Dockerfile that we can use for testing. By entering the above and pressing enter, we’ve just created a new Dockerfile and populated three zero-byte test files in the same directory.
Also, the program can be updated to be able to automatically recover files from the container and store them locally, while also automatically making appropriate updates to the Dockerfile. Finally, the program can also be updated to be able to easily infer if the base layer is using an empty scratch image, or something else.
You can check how an image was created using docker history <image-name> --no-trunc
Update:
Check dive which is a very nice tool that allows you to views image layers.
As yamenk said docker history
is the key to this.
As https://github.com/CenturyLinkLabs/dockerfile-from-image is broken, you can use recent
https://hub.docker.com/r/dduvnjak/dockerfile-from-image/
Extract from the site
Note that the script only works against images that exist in your local image repository (the stuff you see when you type docker images). If you want to generate a Dockerfile for an image that doesn't exist in your local repo you'll first need to docker pull it.
For example, you can run it agains itself, to see the code
$ docker run --rm -v /run/docker.sock:/run/docker.sock centurylink/dockerfile-from-image ruby FROM buildpack-deps:latest RUN useradd -g users user RUN apt-get update && apt-get install -y bison procps RUN apt-get update && apt-get install -y ruby ADD dir:03090a5fdc5feb8b4f1d6a69214c37b5f6d653f5185cddb6bf7fd71e6ded561c in /usr/src/ruby WORKDIR /usr/src/ruby RUN chown -R user:users . USER user RUN autoconf && ./configure --disable-install-doc RUN make -j"$(nproc)" RUN make check USER root RUN apt-get purge -y ruby RUN make install RUN echo 'gem: --no-rdoc --no-ri' >> /.gemrc RUN gem install bundler ONBUILD ADD . /usr/src/app ONBUILD WORKDIR /usr/src/app ONBUILD RUN [ ! -e Gemfile ] || bundle install --system
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With