11

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!

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Carlos Andres
  • 12,740
  • 7
  • 18
  • 34

1 Answers1

20

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>
0x90
  • 39,472
  • 36
  • 165
  • 245
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Reportedly centurylink/dockerfile-from-image doesn't work (didn't work on my side either): https://stackoverflow.com/questions/19104847/how-to-generate-a-dockerfile-from-an-image/48444917#comment77612772_30793515 alpine/dfimage mentioned in the answer commented by the comment referred works fine as of 2020-07-21. – Alexander Ites Jul 21 '20 at 10:20