Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check what's inside of a docker image?

Tags:

docker

Searching for a best-fit image for a project, you traverse the Docker's Hub and encounter many images. Depending on what they offer, you can choose between slim, alpine, buster, versioned images, latest image, etc.

How to see what's inside an image (what kind of layers are there)? Is it possible to list libraries and drivers contained in an image? How can I ensure my Redis image has proper drivers and libraries to work with Django? How to see if an image utilizes apt, apt-get, apk for package management, or if it doesn't provide such utility at all?

Also, I'd like to check it before fetching an image from Hub, if possible. Launching docker run -it [...] is a way to make such checks, but not very efficient if we have to download >1GB image beforehand.

like image 693
AbreQueVoy Avatar asked Sep 17 '25 15:09

AbreQueVoy


1 Answers

Can run an interactive shell container using that image and can check what are there inside the image.

docker run -it image_name sh

and once the image is built you can view all the layers that make up the image by running the below command

docker history <image_id>

To know what's there in each layer, you need to view the layers on the docker host at /var/lib/docker/aufs AUFS(Another Union FileSystem)

The /var/lib/docker/aufs points to diff, mnt, layers directories.

  1. Image layers and their contents are stored in the diff directory.
  2. Running containers are mounted below the mnt directory (more explained below about mounts).
  3. How image layers are stacked is in the layers directory.

Can check dive a tool for exploring docker image, layer contents etc

like image 90
Ashok Avatar answered Sep 19 '25 05:09

Ashok