I have a set of Docker base images within my organization. I have one per technology stack (Java or Python for example). I can also build these base images for a specific version of Java and push it to the artifactory.
We will then have different projects who will use these base images and construc their Dockerfile. We now want to somehow ensure during the build process of those projects that they did infact use the base image that I created in their Dockerfile!
For example., if the image that I created for Java on Alipine is called
java-8-alpine-3
Then the project that would need a Java runtime should have this as their first line:
FROM java-8-alipne-3
How do I ensure that this is the case? In other words, how can I inspect the images to check for usage of such properties?
well for a particular image you can use century link image which will reverse engineer the docker image
click here for more info
unfortunately century link image use docker tree command which is depreciated so the other solution is to use this
it will display all the layers you can go through inspecting all the layers then .
if you just need to know the
FROM xxx
line used to build your images, just dodocker history --no-trunc my_image
and you will get that information
The doc
https://docs.docker.com/engine/reference/commandline/history/
Edit:
https://hub.docker.com/r/dduvnjak/dockerfile-from-image/
is a fixed version of
https://github.com/CenturyLinkLabs/dockerfile-from-image/issues/14
which no longer works
for example
$ docker run -v /var/run/docker.sock:/var/run/docker.sock dduvnjak/dockerfile-from-image k3ck3c/nethogs FROM alpine:latest RUN apk update && apk add wget&& wget --no-check-certificate -c http://github.com/raboof/nethogs/archive/v0.8.1.tar.gz && tar zvxf v0.8.1.tar.gz && cd ./nethogs-0.8.1/ && echo "export ARCH=x86" >> Makefile && apk add sudo linux-headers ncurses-dev libpcap-dev make g++&& echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && apk update && apk add libpcap libstdc++ libgcc nethogs@testing&& make && sudo make install&& apk del sudo g++ make linux-headers ncurses-dev libpcap-dev libpcap libgcc libstdc++ && rm -rf /var/cache/apk/* ./nethogs-0.8.1/
shows the
FROM
line correctly
or just
$ docker run -v /var/run/docker.sock:/var/run/docker.sock dduvnjak/dockerfile-from-image k3ck3c/nethogs | grep FROM FROM alpine:latest
You cannot get
FROM
line just having the image.You can use
docker history --no-trunc image_name
to get the history of an image, but you can't getFROM
line.Take a look to this thread on Docker forum for further information: https://forums.docker.com/t/how-can-i-view-the-dockerfile-in-an-image/5687/3