Skip to content

Docker: Software versions inside containers & images

9 Docker commands: Software versions inside containers & images. Click a command to see what each part does.

Index
9 items
Click a command to see what each part does.

Software versions inside containers & images9

  • docker exec <container> cat /etc/os-releaseWhich OS and version is the container based on?

    What each part does

    1. docker exec <container>run inside the container
    2. cat /etc/os-releasedistro name and version, e.g. Debian 12, Alpine 3.20, UBI 9
  • docker exec <container> sh -c 'dpkg -l 2>/dev/null || rpm -qa 2>/dev/null || apk info -v'List installed OS packages with versions (any distro)

    What each part does

    1. sh -c '...'run a small shell script inside the container
    2. dpkg -lDebian / Ubuntu packages and versions
    3. 2>/dev/null ||hide the error and try the next tool if this one doesn't exist
    4. rpm -qaRHEL / UBI / Amazon Linux packages
    5. apk info -vAlpine packages with versions
  • docker exec <container> sh -c 'dpkg-query -W <package> 2>/dev/null || rpm -q <package> 2>/dev/null || apk info -v <package>'Version of one package in a container

    What each part does

    1. dpkg-query -W <package>Debian / Ubuntu: name and installed version
    2. rpm -q <package>RHEL family: name-version-release
    3. apk info -v <package>Alpine: name-version
  • docker run --rm <image>:<tag> <program> --versionVersion of the app runtime in an image

    What each part does

    1. docker run --rm <image>:<tag>throwaway container from the image
    2. <program> --versione.g. node --version, python3 --version, java -version, nginx -v
  • docker image inspect <image>:<tag> --format '{{index .Config.Labels "org.opencontainers.image.version"}}'Image version labels (OCI annotations)

    What each part does

    1. docker image inspect <image>:<tag>image metadata
    2. {{index .Config.Labels "..."}}read one label; the OCI version label is set by many official images and good pipelines
  • docker image inspect <image>:<tag> --format '{{.Id}} {{index .RepoDigests 0}} {{.Created}} {{.Os}}/{{.Architecture}}'Image ID, digest, created date and architecture

    What each part does

    1. {{.Id}}local image ID
    2. {{index .RepoDigests 0}}registry digest (repo@sha256:...) to pin exactly this image
    3. {{.Created}}build date
    4. {{.Os}}/{{.Architecture}}platform, e.g. linux/amd64 or linux/arm64
  • docker inspect <container> --format '{{.Config.Image}} {{.Image}}'Which image (and digest) is a container running?

    What each part does

    1. {{.Config.Image}}the name:tag it was started from
    2. {{.Image}}the exact image ID, so you can tell if :latest has moved since
  • docker manifest inspect <image>:<tag> | jq '.manifests[].platform'Check which platforms an image supports, without pulling

    What each part does

    1. docker manifest inspectread the image manifest from the registry
    2. | jq '.manifests[].platform'list os/architecture of every variant (multi-arch images)
  • docker scout quickview <image>:<tag>Quick vulnerability overview of an image

    What each part does

    1. docker scout quickviewsummary of known CVEs by severity and base image update advice (Docker Scout plugin)
    2. <image>:<tag>local or registry image

    Tip docker scout cves <image> lists every CVE. Trivy does the same without Docker's plugin.

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…