10

Is there a way to check if the docker image has all of the files that the Dockerfile copies over and to understand if the image is built as configured in the Dockerfile? My situation is that the image is built successfully, however when I try running it, docker complains that it cant find some file or other and the container fails to run, so I cant exec on it.

Doing docker inspect is not helping since it does not report on the files in the image. Is there some method?

sharman
  • 515
  • 1
  • 5
  • 18
  • Post the Dockerfile or the docker-compose file – user2915097 Jun 23 '17 at 17:28
  • Thanks. I did fix the problem. My bad I had a touch cmd which was not populating. However, the question still stands. What does one do to check the contents of an image when there are no build errors? Any inputs? – sharman Jun 23 '17 at 20:31

2 Answers2

26

You can run a shell based on that image:

docker run -it <image-name> bash

Use sh instead if there is no bash available. There you can search for files as any shell.

But maybe you have not bash in the image, so use sh:

docker run -it <image-name> sh

But maybe you have an odd entrypoint, so override it:

docker run -it --entrypoint sh <image-name>
Robert
  • 33,429
  • 8
  • 90
  • 94
  • 1
    I don't think that is going to work because it does not produce a prompt. Also, since the image can't be run for any reason then the shell won't be available. May be you can elaborate. I have not had any success with that. – sharman Jun 25 '17 at 23:24
  • I have updated my answer. If it is still not working, show us the output. – Robert Jun 26 '17 at 00:00
1

You can see the history of file and check if all the required files are present at the time of image creation

docker image history --no-trunc [image_name] > [file_name]
grg
  • 5,023
  • 3
  • 34
  • 50
Rajat Srivastava
  • 269
  • 2
  • 10