12

I have downloaded a docker container that performs several different operations on an input file using several different kinds of software, i.e. alignment, variant calling etc. How do I find out what the contents of the docker container/image is? Sorry if this is trivial I am totally new to docker.

Martin S
  • 121
  • 1
  • 1
  • 3

3 Answers3

27

There are (at least) three ways to interpret your question:

  • which packages are installed in the container;
  • what files are there: explore container's filesystem;
  • what images and layers does the container consist of?

1. List packages installed in container

The way to get list of installed packages depends on distribution. There are three most popular families:

  • Alpine, lightweight Linux distribution based on musl and BusyBox
  • Debian-based (Debian, Ubuntu)
  • rpm-based (RHEL, CentOS and Fedora)

Alpine-based containers

Use apk info -vv command:

docker exec -i <container_id_1>  apk info -vv | sort

Debian & Ubuntu - based containers

Use dpkg -l command:

docker exec -i <container_id_1>  dpkg -l

RHEL, CentOS and Fedora - based containers

Use rpm -qa or yum list installed command:

docker exec -i <container_id_1>  rpm -qa
docker exec -i <container_id_1>  yum list installed

2. Explore container's filesystem

To see directory structure you can use either bash & tree or cool tools developed specially for exploring docker images

tree

docker exec -i <container_id_1> tree /

Note: not all images contain tree command.

docker export with tar

docker export adoring_kowalevski > contents.tar And then, tou can explore contents.tar with your preferred archiver. I.e. for tar:

tar -tvf contents.tar

3. Special tools (explore images and layers OverlayFS)

wagoodman/dive

wagoodman/dive: A tool for exploring each layer in a docker image

docker run --rm -it \ 
  -v /var/run/docker.sock:/var/run/docker.sock \
  wagoodman/dive:latest \
  <image_name|image_id>

A tool for exploring a docker image, layer contents, and discovering ways to shrink your Docker image size. Image

tomastomecek/sen

TomasTomecek/sen: Terminal User Interface for docker engine

docker run -v /var/run/docker.sock:/run/docker.sock -ti -e TERM tomastomecek/sen

it can interactively manage your containers and images:

justone/dockviz

justone/dockviz: Visualizing Docker data

$ dockviz containers -d -r | dot -Tpng -o containers.png

Containers are visualized with labelled lines for links. Containers that aren't running are greyed out.

$ dockviz containers -d -r | dot -Tpng -o containers.png

Yasen
  • 4,241
  • 1
  • 16
  • 25
2

You can get information concerning the image by using: docker image inspect <image> and docker image history <image> and then if you want to get information concerning the container, simply enter in the running container using exec command docker container exec -itu 0 <container> /bin/bash(pay attention your container may be using another shell) and afterward just gather the needed information (os, running processes, open files, etc)

More information about exec command: https://docs.docker.com/engine/reference/commandline/exec/.

PS: To list images docker image ls , to list running containers docker container ps

dejanualex
  • 3,872
  • 6
  • 22
  • 37
2

Since Docker Desktop 4.7.0 you can use the experimental sbom command to get the "Software Bill of Rights", which is a pretty comprehensive list of all contained libraries and corresponding versions. E.g.

$ docker sbom openjdk:11-jre-slim-buster
Syft v0.43.0
 ✔ Pulled image
 ✔ Loaded image
 ✔ Parsed image
 ✔ Cataloged packages      [91 packages]

NAME                    VERSION                  TYPE
adduser                 3.118                    deb
apt                     1.8.2.3                  deb
base-files              10.3+deb10u12            deb
base-passwd             3.5.46                   deb
bash                    5.0-4                    deb
bsdutils                1:2.33.1-0.1             deb
ca-certificates         20200601~deb10u2         deb
coreutils               8.30-3                   deb
dash                    0.5.10.2-5               deb
debconf                 1.5.71+deb10u1           deb
debian-archive-keyring  2019.1+deb10u1           deb
[...]

As you can see it's based on Syft which is third party tool. That may change in the future though (hence experimental). In fact you can also use Syft directly so you don't need Docker Desktop.

David Ongaro
  • 3,568
  • 1
  • 24
  • 36