AI-Powered Docker Security Analyzer
Project description
DockSec
AI-powered Docker security scanner that explains vulnerabilities in plain English
Quick Start • Features • Installation • Usage • Contributing
What is DockSec?
DockSec combines traditional Docker security scanners (Trivy, Hadolint, Docker Scout) with AI to provide context-aware security analysis. Instead of dumping 200 CVEs and leaving you to figure it out, DockSec:
- 🎯 Prioritizes what actually matters
- 💡 Explains vulnerabilities in plain English
- 🔧 Suggests specific fixes for YOUR Dockerfile
- 📊 Generates professional security reports
Think of it as having a security expert review your Dockerfiles.
Quick Start
# Install
pip install docksec
# Scan your Dockerfile
docksec Dockerfile
# Scan with image analysis
docksec Dockerfile -i myapp:latest
# Scan without AI (no API key needed)
docksec Dockerfile --scan-only
Features
- Smart Analysis: AI explains what vulnerabilities mean for your specific setup
- Multiple Scanners: Integrates Trivy, Hadolint, and Docker Scout
- Security Scoring: Get a 0-100 score to track improvements
- Multiple Formats: Export reports as HTML, PDF, JSON, or CSV
- No AI Required: Works offline with
--scan-onlymode - CI/CD Ready: Easy integration into build pipelines
Installation
Requirements: Python 3.12+, Docker (for image scanning)
pip install docksec
For AI features, set your OpenAI API key:
export OPENAI_API_KEY="your-key-here"
External tools (optional, for full scanning):
# Install Trivy and Hadolint
python -m docksec.setup_external_tools
# Or install manually:
# - Trivy: https://aquasecurity.github.io/trivy/
# - Hadolint: https://github.com/hadolint/hadolint
Usage
Basic Scanning
# Analyze Dockerfile with AI recommendations
docksec Dockerfile
# Scan Dockerfile + Docker image
docksec Dockerfile -i nginx:latest
# Get only scan results (no AI)
docksec Dockerfile --scan-only
# Scan image without Dockerfile
docksec --image-only -i nginx:latest
CLI Options
| Option | Description |
|---|---|
dockerfile |
Path to Dockerfile |
-i, --image |
Docker image to scan |
-o, --output |
Output file path |
--ai-only |
AI analysis only (no scanning) |
--scan-only |
Scanning only (no AI) |
--image-only |
Scan image without Dockerfile |
Configuration
Create a .env file for advanced configuration:
OPENAI_API_KEY=your-key
LLM_MODEL=gpt-4o
TRIVY_SCAN_TIMEOUT=600
See full configuration options.
Example Output
🔍 Scanning Dockerfile...
⚠️ Security Score: 45/100
Critical Issues (3):
• Running as root user (line 12)
• Hardcoded API key detected (line 23)
• Using vulnerable base image
💡 AI Recommendations:
1. Add non-root user: RUN useradd -m appuser && USER appuser
2. Move secrets to environment variables or build secrets
3. Update FROM ubuntu:20.04 to ubuntu:22.04 (fixes 12 CVEs)
📊 Full report: results/nginx_latest_report.html
Examples
Check out example Dockerfiles in examples/:
- Secure Python app - Best practices (Score: 95/100)
- Vulnerable Node app - Common mistakes (Score: 32/100)
- Multi-stage Go build - Advanced patterns (Score: 98/100)
Architecture
Dockerfile → [Trivy + Hadolint + Scout] → AI Analysis → Reports
DockSec runs security scanners locally, then uses GPT-4 to:
- Combine and deduplicate findings
- Assess real-world impact for your context
- Generate actionable remediation steps
- Calculate security score
All scanning happens on your machine. Only scan results (not your code) are sent to OpenAI when using AI features.
Roadmap
- Docker Compose support
- Kubernetes manifest scanning
- Additional LLM providers (Claude, local models)
- GitHub Actions integration
- Custom security policies
See open issues or suggest features in discussions.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Quick links:
Documentation
Troubleshooting
"No OpenAI API Key provided"
→ Set OPENAI_API_KEY or use --scan-only mode
"Hadolint not found"
→ Run python -m docksec.setup_external_tools
"Python version not supported"
→ DockSec requires Python 3.12+. Use pyenv install 3.12 to upgrade.
"Where are my scan results?"
→ Results are saved to results/ directory in your DockSec installation
→ Customize location: export DOCKSEC_RESULTS_DIR=/custom/path
For more issues, see Troubleshooting Guide.
License
MIT License - see LICENSE for details.
Links
- PyPI: https://pypi.org/project/docksec/
- Issues: https://github.com/advaitpatel/DockSec/issues
- Discussions: https://github.com/advaitpatel/DockSec/discussions
If DockSec helps you, give it a ⭐ to help others discover it!
Built with ❤️ by Advait Patel
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docksec-2026.1.24.tar.gz.
File metadata
- Download URL: docksec-2026.1.24.tar.gz
- Upload date:
- Size: 35.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
828a62db412594fdfa4cc078ee6e59a6cd8b61d3fef96f1af0dec816a536176a
|
|
| MD5 |
d3477dd468fd04095a20c0e0f7efb3a2
|
|
| BLAKE2b-256 |
132dbe8ddf787f1c962dbfdeb77397bb6a98cef1546edb40b6acc1d5705cbb63
|
File details
Details for the file docksec-2026.1.24-py3-none-any.whl.
File metadata
- Download URL: docksec-2026.1.24-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc897ca4048f24cf4cfff291a6dafc0c119b120fecc1d80e03c57ca97bd073d2
|
|
| MD5 |
bcad11f51d254f6d400ae15f2beb8621
|
|
| BLAKE2b-256 |
326c9cc2b77f306a89d4aec04005a33975fbb8dae463aa6505a4a1766cbc0fb7
|