Your security scan just flagged 47 vulnerabilities in your production container image. Most of them are OS-level packages you didn't even know were there.
The traditional solution? Rebuild the entire image, update base images, wait for upstream fixes, redeploy everything. This takes hours or days.
There's a better way.
The problem with container vulnerabilities
Container images bundle your application code with OS packages, libraries, and dependencies. When a security vulnerability is discovered in any of these components, you're exposed.
The typical workflow looks like this:
- Security scanner finds vulnerabilities
- Wait for upstream base image updates
- Rebuild your image
- Test everything again
- Deploy
This process is slow. During that time, your vulnerable containers are running in production.
The tools: Trivy + Copa
Trivy is a vulnerability scanner that finds security issues in container images, filesystems, and git repositories. It's fast, accurate, and open source.
Copa (short for Copacetic) patches container images directly by applying security updates to vulnerable OS packages. No rebuilds required.
Together, they let you scan for vulnerabilities and patch them in seconds.
Installing the tools
For Linux or other platforms, check the official docs:
- Trivy: https://aquasecurity.github.io/trivy/latest/getting-started/installation/
- Copa: https://project-copacetic.io/docs/installation/
Scanning for vulnerabilities
First, scan your image to see what you're dealing with:
The flags explained:
--pkg-types os- Only scan OS packages (not language-specific dependencies)--ignore-unfixed- Skip vulnerabilities without available patches--scanners vuln- Only run vulnerability scanning (not misconfigurations, secrets, etc.)
Patching vulnerabilities automatically
Here's where it gets good. Generate a vulnerability report and apply patches:
Copa reads the Trivy report, identifies which packages need updates, and applies security patches directly to the image layers. It creates a new patched image without rebuilding from source.
Real example: patching a vulnerable image
Let me show you the complete workflow I use. Here's a Makefile that makes this trivial:
Usage:
Before and after results
Here's what the output looks like when scanning a typical Node.js application image:
Before patching:
After patching:
The patched image went from 47 vulnerabilities to zero in under 30 seconds.
How Copa works under the hood
Copa doesn't rebuild your image from scratch. Instead, it:
- Analyzes the vulnerability report from Trivy
- Downloads the updated packages for vulnerable components
- Creates new image layers with patched packages
- Preserves all your application code and custom configurations
This is way faster than rebuilding because it only touches the packages that need updates.
Important limitations
Copa is powerful but has constraints you need to understand:
1. OS packages only
Copa patches OS-level packages (apt, apk, yum packages). It doesn't patch:
- Language-specific dependencies (npm packages, Python packages, Go modules)
- Application code vulnerabilities
- Custom compiled software
For these, you still need to update your source and rebuild.
2. Only patches with available fixes
The --ignore-unfixed flag is important. Copa can only apply patches when upstream maintainers have released security updates. If a vulnerability has no fix available yet, Copa can't help.
3. Base image matters
Copa works best with official base images that have active security maintenance:
debian,ubuntu,alpine- Goodnode,python,nginx- Good (based on maintained images)- Random images from Docker Hub - Risky
Integrating into CI/CD
You can integrate vulnerability patching into your CI/CD pipeline to automatically patch OS vulnerabilities before deployment. This ensures every build is automatically scanned and patched, keeping your container images secure without manual intervention.
When to use Copa vs rebuilding
Use Copa when:
- You need to patch production images quickly
- The vulnerabilities are in OS packages only
- You don't control the base image build process
- You want to patch third-party images (nginx, postgres, etc.)
Rebuild from source when:
- Vulnerabilities are in application dependencies
- You're making code changes anyway
- You want to update the base image version
- You need to change build-time configurations
For most production systems, use both: Copa for emergency patches, scheduled rebuilds for comprehensive updates.
Takeaways
-
Copa patches OS vulnerabilities in seconds - No need to rebuild entire images just to update system packages
-
Use --ignore-unfixed - Only focus on vulnerabilities that actually have patches available
-
OS packages only - Copa handles system-level vulnerabilities, not application dependencies
-
Integrate into CI/CD - Automate vulnerability patching so every deployed image is secure
-
Not a replacement for rebuilding - Use Copa for quick patches, but still rebuild regularly for comprehensive updates
-
Test patched images - Even though Copa is safe, always test patched images before deploying to production
The speed difference
Traditional approach to fixing a critical vulnerability:
- Wait for base image update: 1-3 days
- Rebuild image: 5-10 minutes
- Run tests: 10-30 minutes
- Deploy: 5-10 minutes
Total: Hours to days
Copa approach:
- Scan: 30 seconds
- Patch: 20 seconds
- Deploy: 5-10 minutes
Total: Minutes
That's the difference between responding to a critical CVE in under an hour versus waiting days for fixes to trickle through the supply chain.
When zero-day vulnerabilities drop, every hour counts.