Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see Dockerfile for each docker image?

I have the following docker images.

$ docker images REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE hello-world         latest              48b5124b2768        2 months ago        1.84 kB docker/whalesay     latest              6b362a9f73eb        22 months ago       247 MB 

Is there a way I can see the Dockerfile of each docker image on my local system?

The answer at Where to see the Dockerfile for a docker image? does not help me because it does not exactly show the Dockerfile but the commands run to create the image. I want the Dockerfile itself.

like image 767
Lone Learner Avatar asked Apr 09 '17 17:04

Lone Learner


People also ask

Does docker image contain Dockerfile?

From Dockerfile to Image to Container It all starts with a script of instructions that define how to build a specific Docker image. This script is called a Dockerfile. The file automatically executes the outlined commands and creates a Docker image. The command for creating an image from a Dockerfile is docker build .

Where can I find the Dockerfile?

Traditionally, the Dockerfile is called Dockerfile and located in the root of the context. You use the -f flag with docker build to point to a Dockerfile anywhere in your file system. $ docker build -f /path/to/a/Dockerfile .

Can we see the docker image content?

You can run an interactive shell container using that image and explore whatever content that image has. The steps will be logged into the image_history file. Show activity on this post. Show activity on this post.

Which command is used to show all docker images?

In order to list the Docker containers, we can use the “docker ps” or “docker container ls” command. This command provides a variety of ways to list and filter all containers on a particular Docker engine.


2 Answers

As far as I know, no, you can't. Because a Dockerfile is used for building the image, it is not packed with the image itself. That means you should reverse engineer it. You can use docker inspect on an image or container, thus getting some insight and a feel of how it is configured. The layers an image are also visible, since you pull them when you pull a specific image, so that is also no secret.

However, you can usually see the Dockerfile in the repository of the image itself on Dockerhub. I can't say most repositories have Dockerfiles attached, but the most of the repositories I seen do have it.

Different repository maintainers may opt for different ways to document the Dockerfiles. You can see the Dockerfile tab on the repository page if automatic builds are set up. But when multiple parallel versions are available (like for Ubuntu), maintainers usually opt to put links the Dockerfiles for different versions in the description. If you take a look here: https://hub.docker.com/_/ubuntu/, under the "Supported tags" (again, for Ubuntu), you can see there are links to multiple Dockerfiles, for each respective Ubuntu version.

like image 198
Aleksandar Stojadinovic Avatar answered Sep 18 '22 09:09

Aleksandar Stojadinovic


As the images are downloaded directly from the Dockerhub, only the image is pulled from the docker hub into your machine. If you want to see the dockerfile, then you can go to docker hub and type the image name and version name in the tag format (e.g ubuntu:14.04) this will open the image along with Docker file details. Also keep in mind, only if the owner of the image shared their Dockerfile, you can see it. Otherwise not. Most official images will not provide you with Dockerfile.

Hope it helps!

like image 41
Jayabalan Bala Avatar answered Sep 21 '22 09:09

Jayabalan Bala