Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if the docker image has all the files?

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?

like image 854
sharman Avatar asked Jun 23 '17 17:06

sharman


People also ask

Does docker image contain files?

A Docker image contains application code, libraries, tools, dependencies and other files needed to make an application run.

Where does docker store all files?

Volumes are stored in a part of the host filesystem which is managed by Docker ( /var/lib/docker/volumes/ on Linux). Non-Docker processes should not modify this part of the filesystem. Volumes are the best way to persist data in Docker.


2 Answers

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>
like image 69
2 revs Avatar answered Sep 29 '22 10:09

2 revs


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]
like image 39
Rajat Srivastava Avatar answered Sep 29 '22 09:09

Rajat Srivastava