![]() ![]() These entries have been changed between myapp/myservice:v1: and myapp/myservice:v2: These entries have been deleted from myapp/myservice:v1: app/node_modules/fsevents/README.md 2.9K These entries have been added to myapp/myservice:v1: To see all the file changes, run container-diff with -type=file: $ container-diff diff -type=file myapp/myservice:v1 myapp/myservice:v2 ![]() Packages found only in python:3.10-bullseye: None Use case 2: troubleshooting containersĭebugging a failing container is easy when we have a healthy image to use as a reference. Packages found only in python:3.6.15-buster: Or changes in Python packages: $ container-diff diff -type=pip python:3.6.15-buster python:3.10-bullseye PACKAGE IMAGE1 (node:16) IMAGE2 (node:17) In the same vein, we can compare globally-installed Node packages: $ container-diff diff -type=node node:16 node:17 Image size difference between postgres:13 and postgres:14: We can list what changed at the OS level: $ container-diff diff -type=size -type=apt postgres:13 postgres:14 And, as we’ll see in the next section, the output format can be customized using a template. Use case 1: generating a changelogĬontainer-diff works great for generating changelogs. Let’s see some use cases for image comparison. The command for this is: container-diff diff Container-diff really shines when comparing images. We’re only scratching the surface so far. Useradd -r -g postgres -uid=999 -home-dir=/var/lib/postgresql -shell=/bin/bash postgresĬhown -R postgres:postgres /var/lib/postgresql $ container-diff analyze -type=history postgres:14 | sed 's/ */ /g s/ /\n\t/g' The output of -type=history is hard to read, so we’ll format it with sed. ? Use -order to show files ordered by size instead of alphabetically.įinally, the history test shows the Docker layers, which roughly reflect the Dockerfile. $ container-diff analyze -type=file postgres:14 You can see every file in the image with -type=file, along with its size. $ container-diff analyze -type=pip python:3.10-bullseye Similarly, you can get a list of globally-installed packages for Node and Python with -type=node and -type=pip. ![]() $ container-diff analyze -type=apt postgres:14 Change it to -type=apt to find out which OS-level packages are installed. So, for instance, we can analyze a PostgreSQL image with: $ container-diff analyze postgres:14 Then, the contents are scanned, and a report is printed out. The tool pulls the image from the registry and unpacks the filesystem into $HOME/.container-diff/cache. The command to analyze an image looks like this: container-diff analyze Layer history: prints the commands that generated each of the layers in the image.Filesystem: shows all the files in the image and their size.Packages: shows a list of OS-installed packages (only for Debian-based distros), as well as those installed with pip and npm.Testing containersĬontainer-diff has the following test modes: The project, developed by many of the same faces behind Container Structure Tests, does a lot more than just diffing: it can analyze container images, show installed packages, and reverse-engineer the commands used to generate them. Introducing container-diffĪvailable in macOS, Linux, and Windows, container-diff (like the name suggests) is diff for container images. So, let’s elaborate a bit more in our container-diff tutorial. Fortunately, where there’s a need, there’s a tool. But change is inevitable, and while commits on Dockerfiles are easy to control, the impact of those changes on the resulting image are not. We know that an innocent-looking change can have branching, hard-to-debug consequences. Touching a working Dockerfile can feel like playing with fire. ![]()
0 Comments
Leave a Reply. |