brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: docker diff shows what a container changed in its filesystem

Docker
~/tips/tip-docker-docker-diff

docker diff mycontainer

Lists every file a container added, changed or deleted compared to its image.

A container works, but nobody remembers where it writes its files. docker diff answers that without any digging.

It compares the container’s filesystem with the image it came from and lists the difference.

docker diff mycontainer

Each line starts with a letter. A is a file or directory that was added, C means changed and D means deleted. In the docs example for nginx you see A /run/nginx.pid and C /var/log/nginx, which tells you right away where it keeps its pid file and its logs.

This is a good first step before you decide which paths need a volume, or whether a container can run with --read-only.

Compose users can run the same thing by container name from docker compose ps. It is read-only, so there is nothing to break and it is safe to try on a container you are unsure about.

The caveat: it only shows changes in the container’s writable layer. Data in a mounted volume or bind mount is not listed, and it is gone when the container is removed, so run it before you delete anything.

Further reading: docker container diff, On this site: watch docker events to see exactly when a container dies, On this site: docker ps –format table gives you a readable overview, On this site: 🐳Comprehensive Guide: Updating Docker Containers via the Unraid Terminal

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link