Detect and report drift between running Docker containers and their original images.
Drift occurs when files, packages, or configurations inside a container are changed without updating the Dockerfile.
- File system change detection (
docker diff) - Package difference checking
- Multiple output formats (Markdown / JSON)
- CI/CD-friendly exit codes for automation
In DevOps and production environments, containers often drift when:
- Packages are manually installed inside running containers
- Configurations are updated without changing the image
- Security patches are applied directly in containers
This leads to:
- ❌ Inconsistent environments
- ❌ Security vulnerabilities
- ❌ Hard-to-reproduce bugs
Docker Drift helps catch those issues early.
Clone the repo and make the script executable:
git clone https://github.com/<your-username>/docker-drift.git
cd docker-drift
chmod +x dockerdrift.sh- Start a container to test drift:
docker run -d --name my-test-container ubuntu sleep 60
#Install a package manually inside the container to simulate drift:
docker exec my-test-container apt-get update
docker exec my-test-container apt-get install -y curl
#Run Docker Drift:
./dockerdrift.sh my-test-containerScanning container: my-test-container
Filesystem Drift:
C /etc/apt/sources.list
A /usr/bin/curl
Package Drift:
Added:
curl 8.2.1-1ubuntu3
After running drift.sh, an HTML report (drift-report.html) will be generated automatically in the same folder.
The report shows:
- Filesystem drift (Added / Changed / Deleted files)
- Package drift (Added / Removed packages)
- Summary counts To open the HTML Report, you need to run a command depending on your OS
xdg-open drift-report.htmlopen drift-report.htmlexplorer drift-report.htmlOpen your browser and navigate to file:///path/to/drift-report.html.
- Push a change to your repo (or open a pull request).
- GitHub Actions will automatically run
drift.shand report drift in the workflow logs.
During testing (for example, in the Step-by-Step Example and GitHub Actions), we sometimes compare two running containers instead of a container and its original image. This is for demonstration purposes: one container simulates the “original” image, while the other is modified to show how drift is detected. In practice, Docker Drift compares a container to its original image to detect filesystem or package changes.