Compare installed packages between 2 docker images.

Why?

An, eventually abandoned, attempt to transition from node: x,x,x to node: x,x,x-slim. I needed to determine which packages were excluded in the node - slim image.

Given any two images, I use this script to compare the installed packages. This works with debian based images.

IMAGE_ONE=node:lts
IMAGE_TWO=node:lts-slim

comm -23 <(sort <(docker run $IMAGE_ONE apt list --installed)) <(sort <(docker run $IMAGE_TWO apt list --installed))

This will list out the packages present in “Image_One” and not “Image_Two”.