Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show a dockerfile of image docker

I download a image from docker repository and Im trying to display the Dockerfile of 'X' image to create my own Dockerfile with the same structure to experiment with him. Im using this command:

docker inspect --format='{{.Config.Image}}' 'here paste the id of image'

That command return a 'sha256', some like this:

sha256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

but I need a command to display a json file with configuration of Dockerfile. Someone know how can I do this? Sorry if the format or the question is not ok, Im a beginner!

Thanks everyone!

like image 636
Carlos Andres Avatar asked Feb 10 '18 02:02

Carlos Andres


1 Answers

The raw output, as described in "How to generate a Dockerfile from an image?", would be:

docker history --no-trunc <IMAGE_ID>

But a more complete output would be from CenturyLinkLabs/dockerfile-from-image

docker run -v /var/run/docker.sock:/var/run/docker.sock \
 centurylink/dockerfile-from-image <IMAGE_TAG_OR_ID>

Note there were limitations.

In 2020, as illustrated here:

docker run -v /var/run/docker.sock:/var/run/docker.sock --rm alpine/dfimage \
  -sV=1.36 <IMAGE_TAG_OR_ID>
like image 136
VonC Avatar answered Nov 05 '22 01:11

VonC