anchore is a free and open-source container analysis. Anchore provides deep image inspection and vulnerability scanning
1. Prerequisites
2. Supported Operating Systems
This guide supports installation on:
3. Installation
RHEL/CentOS/Rocky Linux/AlmaLinux
bash
# Install EPEL repository if needed
sudo dnf install -y epel-release
# Install anchore
sudo dnf install -y anchore
# Enable and start service
sudo systemctl enable --now anchore
# Configure firewall
sudo firewall-cmd --permanent --add-port=8228/tcp
sudo firewall-cmd --reload
# Verify installation
anchore --version
Debian/Ubuntu
bash
# Update package index
sudo apt update
# Install anchore
sudo apt install -y anchore
# Enable and start service
sudo systemctl enable --now anchore
# Configure firewall
sudo ufw allow 8228
# Verify installation
anchore --version
Arch Linux
bash
# Install anchore
sudo pacman -S anchore
# Enable and start service
sudo systemctl enable --now anchore
# Verify installation
anchore --version
Alpine Linux
bash
# Install anchore
apk add --no-cache anchore
# Enable and start service
rc-update add anchore default
rc-service anchore start
# Verify installation
anchore --version
openSUSE/SLES
bash
# Install anchore
sudo zypper install -y anchore
# Enable and start service
sudo systemctl enable --now anchore
# Configure firewall
sudo firewall-cmd --permanent --add-port=8228/tcp
sudo firewall-cmd --reload
# Verify installation
anchore --version
macOS
bash
# Using Homebrew
brew install anchore
# Start service
brew services start anchore
# Verify installation
anchore --version
FreeBSD
bash
# Using pkg
pkg install anchore
# Enable in rc.conf
echo 'anchore_enable="YES"' >> /etc/rc.conf
# Start service
service anchore start
# Verify installation
anchore --version
Windows
bash
# Using Chocolatey
choco install anchore
# Or using Scoop
scoop install anchore
# Verify installation
anchore --version
Initial Configuration
Basic Configuration
bash
# Create configuration directory
sudo mkdir -p /etc/anchore
# Set up basic configuration
# See official documentation for detailed configuration options
# Test configuration
anchore --version
5. Service Management
systemd (RHEL, Debian, Ubuntu, Arch, openSUSE)
bash
# Enable service
sudo systemctl enable anchore
# Start service
sudo systemctl start anchore
# Stop service
sudo systemctl stop anchore
# Restart service
sudo systemctl restart anchore
# Check status
sudo systemctl status anchore
# View logs
sudo journalctl -u anchore -f
OpenRC (Alpine Linux)
bash
# Enable service
rc-update add anchore default
# Start service
rc-service anchore start
# Stop service
rc-service anchore stop
# Restart service
rc-service anchore restart
# Check status
rc-service anchore status
rc.d (FreeBSD)
bash
# Enable in /etc/rc.conf
echo 'anchore_enable="YES"' >> /etc/rc.conf
# Start service
service anchore start
# Stop service
service anchore stop
# Restart service
service anchore restart
# Check status
service anchore status
launchd (macOS)
bash
# Using Homebrew services
brew services start anchore
brew services stop anchore
brew services restart anchore
# Check status
brew services list | grep anchore
Windows Service Manager
powershell
# Start service
net start anchore
# Stop service
net stop anchore
# Using PowerShell
Start-Service anchore
Stop-Service anchore
Restart-Service anchore
# Check status
Get-Service anchore
Advanced Configuration
See the official documentation for advanced configuration options.
Reverse Proxy Setup
nginx Configuration
nginx
upstream anchore_backend {
server 127.0.0.1:8228;
}
server {
listen 80;
server_name anchore.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name anchore.example.com;
ssl_certificate /etc/ssl/certs/anchore.example.com.crt;
ssl_certificate_key /etc/ssl/private/anchore.example.com.key;
location / {
proxy_pass http://anchore_backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Apache Configuration
apache
<VirtualHost *:80>
ServerName anchore.example.com
Redirect permanent / https://anchore.example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName anchore.example.com
SSLEngine on
SSLCertificateFile /etc/ssl/certs/anchore.example.com.crt
SSLCertificateKeyFile /etc/ssl/private/anchore.example.com.key
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8228/
ProxyPassReverse / http://127.0.0.1:8228/
</VirtualHost>
HAProxy Configuration
haproxy
frontend anchore_frontend
bind *:80
bind *:443 ssl crt /etc/ssl/certs/anchore.pem
redirect scheme https if !{ ssl_fc }
default_backend anchore_backend
backend anchore_backend
balance roundrobin
server anchore1 127.0.0.1:8228 check
Security Configuration
Basic Security Setup
bash
# Set appropriate permissions
sudo chown -R anchore:anchore /etc/anchore
sudo chmod 750 /etc/anchore
# Configure firewall
sudo firewall-cmd --permanent --add-port=8228/tcp
sudo firewall-cmd --reload
# Enable SELinux policies (if applicable)
sudo setsebool -P httpd_can_network_connect on
Database Setup
See official documentation for database configuration requirements.
Performance Optimization
System Tuning
bash
# Basic system tuning
echo 'net.core.somaxconn = 65535' | sudo tee -a /etc/sysctl.conf
echo 'net.ipv4.tcp_max_syn_backlog = 65535' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
Monitoring
Basic Monitoring
bash
# Check service status
sudo systemctl status anchore
# View logs
sudo journalctl -u anchore -f
# Monitor resource usage
top -p $(pgrep anchore)
9. Backup and Restore
Backup Script
bash
#!/bin/bash
# Basic backup script
BACKUP_DIR="/backup/anchore"
DATE=$(date +%Y%m%d_%H%M%S)
mkdir -p "$BACKUP_DIR"
tar -czf "$BACKUP_DIR/anchore-backup-$DATE.tar.gz" /etc/anchore /var/lib/anchore
echo "Backup completed: $BACKUP_DIR/anchore-backup-$DATE.tar.gz"
Restore Procedure
bash
# Stop service
sudo systemctl stop anchore
# Restore from backup
tar -xzf /backup/anchore/anchore-backup-*.tar.gz -C /
# Start service
sudo systemctl start anchore
6. Troubleshooting
Common Issues
1. Service won't start:
bash
# Check logs
sudo journalctl -u anchore -n 100
sudo tail -f /var/log/anchore/anchore.log
# Check configuration
anchore --version
# Check permissions
ls -la /etc/anchore
2. Connection issues:
bash
# Check if service is listening
sudo ss -tlnp | grep 8228
# Test connectivity
telnet localhost 8228
# Check firewall
sudo firewall-cmd --list-all
3. Performance issues:
bash
# Check resource usage
top -p $(pgrep anchore)
# Check disk I/O
iotop -p $(pgrep anchore)
# Check connections
ss -an | grep 8228
Integration Examples
Docker Compose Example
yaml
version: '3.8'
services:
anchore:
image: anchore:latest
ports:
- "8228:8228"
volumes:
- ./config:/etc/anchore
- ./data:/var/lib/anchore
restart: unless-stopped
Maintenance
Update Procedures
bash
# RHEL/CentOS/Rocky/AlmaLinux
sudo dnf update anchore
# Debian/Ubuntu
sudo apt update && sudo apt upgrade anchore
# Arch Linux
sudo pacman -Syu anchore
# Alpine Linux
apk update && apk upgrade anchore
# openSUSE
sudo zypper update anchore
# FreeBSD
pkg update && pkg upgrade anchore
# Always backup before updates
tar -czf /backup/anchore-pre-update-$(date +%Y%m%d).tar.gz /etc/anchore
# Restart after updates
sudo systemctl restart anchore
Regular Maintenance
bash
# Log rotation
sudo logrotate -f /etc/logrotate.d/anchore
# Clean old logs
find /var/log/anchore -name "*.log" -mtime +30 -delete
# Check disk usage
du -sh /var/lib/anchore
Additional Resources
---
Note: This guide is part of the HowToMgr collection. Always refer to official documentation for the most up-to-date information.