Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.
Cloud & DevOps

Container Image Slimming and Vulnerability Diff Report in CI, Verified by Your Own Tests

Build a CI step that takes an application's container image, produces a slimmed version that keeps only the files the app actually uses, runs the project's own tests against the slim image to prove nothing broke, and reports the size saved and the known vulnerabilities removed. Teams get smaller, safer images without hand-tuning Dockerfiles, and a clear report they can trust.

Difficulty

Beginner

Achievable by one student in a semester with familiar tools.
Effort

1 semester · 2 students

Deliverables

7 to ship

4 optional extras

Suggested stack

DockerSlimToolkitTrivyGitHub ActionsPython or Bash
A suggestion, not a requirement. Swap anything for what you already know.

What you should ship

  • A GitHub Action that builds the image, runs SlimToolkit with a probe based on the project's own tests or HTTP checks
  • A verification step that runs the test suite or smoke tests against the slim image
  • Trivy scans of both images and a diff of vulnerabilities removed, kept and added
  • A pull request comment with size, layer count, startup time and vulnerability changes
  • Configuration for files that must be kept (certificates, time zone data, locale files)
  • A study on at least 15 open source applications in different languages, recording what broke and why
  • A short guide of common slimming failures and how to fix them

If you have time left

  • Comparison with distroless and Alpine-based rewrites of the same images
  • Automatic suggestions for Dockerfile changes based on what was removed
  • Startup time and memory comparison under load
  • GitLab CI support

The problem: images full of things the app never uses

A typical container image is built from a general-purpose base: a full Linux distribution with a shell, package manager, compilers, documentation and hundreds of libraries. The application uses a small fraction of it. The rest makes images slow to push and pull over Pakistani internet links and through CI, costs registry storage, and above all carries known vulnerabilities. Security scanners report dozens of findings in packages the app never touches, and teams spend time triaging them or learn to ignore them.

Rewriting every Dockerfile by hand on a minimal base is the textbook answer. It takes expertise, and it often breaks things in ways that only show up in production: missing certificates, missing time zone data, a dynamically loaded library.

What already exists and the gap

  • SlimToolkit (formerly DockerSlim), a CNCF Sandbox project, minifies images using static and dynamic analysis, reporting reductions of up to 30 times.
  • Distroless images and Alpine bases offer minimal starting points, at the cost of rewriting Dockerfiles.
  • Trivy and Grype scan images for known vulnerabilities.
  • Multi-stage builds reduce size if the Dockerfile author knows how.

The tools exist, but slimming has a trust problem: how do you know the slim image still works? The gap is a CI step that slims, then verifies with the project's own tests, then reports exactly what changed in size and risk, so teams can adopt slimming safely. A study of what breaks across languages is a useful contribution in itself.

Inspiration

"Cimplifier: Automatically Debloating Containers" by Vaibhav Rastogi, Drew Davidson, Lorenzo De Carli, Somesh Jha and Patrick McDaniel (ESEC/FSE 2017) used dynamic analysis to keep only the resources a container needs, preserving functionality while reducing image size by up to 95%. The paper stresses that dynamic analysis only sees the behaviour you exercise, which is exactly why this project ties slimming to the project's own tests.

What you build

  • Developers add one step to their pipeline. Every pull request shows: "image 812 MB to 96 MB; 54 known vulnerabilities removed, 2 remain; all 140 tests pass on the slim image".
  • Security leads see fewer, more relevant findings.
  • When something breaks, the report shows which test failed and which removed files are likely to blame.

The technically interesting part

  • Probing well. SlimToolkit keeps what it sees used while it probes the running container. Drive the probe with the project's own tests or HTTP checks so it exercises real code paths, including error paths.
  • Verifying. Run the full test suite or smoke tests against the slim image. When a test fails, compare the file access traces of the fat and slim runs to point at the missing file.
  • Vulnerability diff. Scan both images and match findings by package and identifier, so the report says what was removed, kept and added.
  • Language differences. Python, Node.js, Java and Go images fail in different ways (dynamic imports, lazy-loaded modules, reflection). Document the patterns in your study.
  • Keeping it repeatable. The slim image must be rebuilt on every change. Cache results between runs and store the keep-list in the repository, so a slimming that worked yesterday is not silently different today.

How to evaluate it

  • Study: for 15 or more open source applications, record size reduction, vulnerability reduction, test results on slim images and the configuration needed to make them pass.
  • Pipeline cost: extra CI time added by slimming and verification.
  • Pull and start time: image pull time on a slow connection and container start time, fat against slim.

Suggested plan

  • Weeks 1 to 3: Docker and SlimToolkit by hand on three sample apps; Trivy scans.
  • Weeks 4 to 6: GitHub Action for build, slim and scan.
  • Weeks 7 to 9: verification step, failure diagnosis and the pull request comment.
  • Weeks 10 to 13: the study across languages and the guide.
  • Weeks 14 to 15: report and demo.

Who it is for, concretely

A small team shipping a Django or Node.js API in a container, whose security scanner shows sixty findings they never have time to read, and whose deploys are slowed by pushing large images over a modest office connection.

Path to a product

Image hardening is a growing commercial category, and companies pay for minimal, low-vulnerability images. An open source action with a clear report is a good entry point, and the cross-language study makes a strong portfolio piece for DevOps and DevSecOps roles.

Scope warning

Wrap SlimToolkit and Trivy; do not build your own analyser or scanner. Choose applications with working test suites for the study. Never ship a slim image that fails verification.

Learn what you need on Sefism

Get help with this idea

This is a good first DevOps project because each week produces something visible. Tauseef can help you choose applications for the study, design the verification step and present the results well. If you are new here, create a free account first.

Ideas and guidance, not finished projects

These are project ideas and scoping guidance, published free for students to use as a starting point. I do not build, write, or sell final-year projects, and I do not complete coursework for anyone. Take an idea, make it yours, and build it.

Not sure this one fits you?

I help students pick an idea that matches their skills and their deadline, then scope it down until it is finishable. Guidance only, never done for you.

Discuss this idea
Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.