BentoPDF now uses nginx-unprivileged for enhanced security. This follows the Principle of Least Privilege and is essential for production environments.
- Reduced Attack Surface: If compromised, attackers won't have root privileges
- Compliance: Meets security standards like SOC 2, PCI DSS
- Kubernetes/OpenShift Compatibility: Works with security policies that require non-root execution
- System Protection: Prevents system-wide damage if the application is compromised
docker build -t bentopdf .
docker run -p 8080:8080 bentopdf# Build with simple mode enabled
docker build --build-arg SIMPLE_MODE=true -t bentopdf-simple .
# Run the container
docker run -p 8080:8080 bentopdf-simpleapiVersion: apps/v1
kind: Deployment
metadata:
name: bentopdf
spec:
template:
spec:
securityContext:
runAsNonRoot: true
runAsUser: 2000
runAsGroup: 2000
containers:
- name: bentopdf
image: bentopdf:latest
ports:
- containerPort: 8080version: '3.8'
services:
bentopdf:
build:
context: .
dockerfile: Dockerfile
args:
SIMPLE_MODE: false
ports:
- '8080:8080'
security_opt:
- no-new-privileges:trueTo verify the container is running as non-root:
# Check the user inside the container
docker exec <container_id> whoami
# Should output: nginx
# Check the user ID
docker exec <container_id> id
# Should show UID/GID for nginx user (typically 101)- Use nginx-unprivileged: Built-in non-root user with minimal privileges
- Regular Updates: Keep the base image updated (currently using 1.29-alpine)
- Port 8080: Use high port numbers to avoid requiring root privileges
- Security Scanning: Regularly scan images for vulnerabilities
- Network Policies: Implement network segmentation
If you encounter permission issues:
- Check file ownership: Ensure all application files are owned by the nginx user
- Verify PID directory: Ensure
/etc/nginx/tmp/directory exists and is writable - Port binding: Ensure port 8080 is available and not blocked by firewall
If migrating from a root-based setup:
- Update your Dockerfile to use nginx-unprivileged base image
- Change port mappings from 80 to 8080 in all configurations
- Update nginx.conf to use
/etc/nginx/tmp/nginx.pidfor PID file - Rebuild your images with the new security settings
- Update your deployment configurations (Kubernetes, Docker Compose, etc.)
- Test thoroughly in a staging environment