Docker Community Forums

Share and learn in the Docker community.

Docker open cli command


(Sachin Sagar Rai) #1

Hi,
Often times I want to see the Dockerfile of the images that I’ve in my host.
Its like bundle open gem_name and it open the files in your fav editor.
Is there any equivalent command like docker open my/image to open up the Dockerfile of the image?


(Andy Rothfusz) #2

The Dockerfile may not be part of the image, so there is no regular way to see the actual file.

You may be able to get most of the information you want from docker history which can show you the command run at each layer of the image, for example:

$ docker history busybox:latest
IMAGE               CREATED             CREATED BY                                      SIZE
a9eb17255234        3 months ago        /bin/sh -c #(nop) CMD [/bin/sh]                 0 B
120e218dd395        3 months ago        /bin/sh -c #(nop) ADD file:88f36b32456f849299   2.433 MB
42eed7f1bf2a        3 months ago        /bin/sh -c #(nop) MAINTAINER Jérôme Petazzo     0 B
511136ea3c5a        15 months ago                                                       0 B

(Sam Saffron) #3

if its in an image … you could automate something that does:

docker run -it --rm -v /tmp:/tmp image cp myfile /tmp

(Sachin Sagar Rai) #4

Well it does put the file if it has been with build with it.
But since I was looking specific Dockerfile, I have to know where the Dockerfile place path is ? But do docker build saves the Dockerfile somewhere inside the image?


(Andy Rothfusz) #5

There is no reason to expect a Dockerfile to be part of an image unless they ADD . as part of the build process.


(Sven Dowideit) #6

There is a plan to add the Dockerfile to the Image’s metadata - but i’m not sure that there’s anyone working on it right now.

I too would love to have this - I can’t find a proposal for it though, so it would be worth your while to make one ( https://github.com/docker/docker/blob/master/CONTRIBUTING.md#design-and-cleanup-proposals )


(Sachin Sagar Rai) #7

Well it does put the file if it has been with build with it.
But since I was looking specific Dockerfile, I have to know where the
Dockerfile place path is ? But do docker build saves the Dockerfile
somewhere inside the image?

@millisami
~Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.com


(Sven Dowideit) #8

There’s nothing special about the Dockerfile so it will only be saved to the image if you ask it to be, and then will be placed wherever you tell it.

ie

COPY . /out would put all the files in your context, Dockerfile included into the /out dir.


(Usertaken) #9

Is there a way to view the full CREATED BY commands from Docker history beyond the first 45 characters?


(Sven Dowideit) #10

I’m 99% sure that the entirety of the meta information in a Docker images can be found using docker inspect.