A secure Docker container running PrivateBin with Apache web server, featuring Prometheus metrics, data persistence, and optimized configuration for production deployments.
- Apache 2.4 with PHP 8.4 (Debian-based)
- PrivateBin version 2.0.3
- Optimized image size (~450-500MB)
- Secure setup with sensitive directories outside document root (
/srv/privatebin) - Prometheus metrics endpoint at
/metrics - Security headers configured
- Data persistence with Docker volumes
- Configuration and data mounted as volumes
# Pull the image
docker pull itefixnet/privatebin
# Run with Docker (with volume mounts)
docker run -d -p 8080:80 \
-v ./data:/srv/privatebin/data \
-v ./conf.php:/srv/privatebin/cfg/conf.php:ro \
--name privatebin itefixnet/privatebin# Build the image
docker build -t privatebin-apache .
# Run with Docker (with volume mounts)
docker run -d -p 8080:80 \
-v ./data:/srv/privatebin/data \
-v ./conf.php:/srv/privatebin/cfg/conf.php:ro \
--name privatebin privatebin-apacheAccess PrivateBin at: http://localhost:8080
The data directory must be mounted as a volume. Optionally mount a custom conf.php:
# Create data directory
mkdir -p data
# Copy sample configuration (optional)
cp conf.php my-conf.php
# Edit my-conf.php as needed
# Set permissions
chmod 770 dataThen mount them when running:
docker run -d -p 8080:80 \
-v ./data:/srv/privatebin/data \
-v ./my-conf.php:/srv/privatebin/cfg/conf.php:ro \
--name privatebin privatebin-apacheOr run without custom config to use defaults:
# Using Docker Hub image
docker run -d -p 8080:80 \
-v ./data:/srv/privatebin/data \
--name privatebin itefixnet/privatebin
# Or using locally built image
docker run -d -p 8080:80 \
-v ./data:/srv/privatebin/data \
--name privatebin privatebin-apacheCustomize the container by setting environment variables:
TZ: Timezone (default: UTC)METRICS_ALLOWED_IPS: Space-separated list of IP addresses allowed to access/metricsendpoint
Example:
docker run -d -p 8080:80 \
-e TZ=America/New_York \
-e METRICS_ALLOWED_IPS="10.0.1.5 192.168.1.10" \
-v ./data:/srv/privatebin/data \
-v ./my-conf.php:/srv/privatebin/cfg/conf.php:ro \
--name privatebin itefixnet/privatebinThe Apache configuration in apache-config.conf includes:
- Privacy-focused: Access logs disabled, error logs only for critical events
- Server identity protection: Server tokens and signatures disabled
- Access restrictions for data directory
- URL rewriting support
docker build -t privatebin-apache .You can build with a specific PrivateBin version using the PRIVATEBIN_VERSION build argument:
docker build --build-arg PRIVATEBIN_VERSION=2.0.3 -t privatebin-apache .Available versions can be found at: https://github.com/PrivateBin/PrivateBin/releases
docker start privatebindocker stop privatebindocker logs -f privatebindocker stop privatebin
docker rm privatebin
docker build -t privatebin-apache .
docker run -d -p 8080:80 \
-v ./data:/srv/privatebin/data \
-v ./my-conf.php:/srv/privatebin/cfg/conf.php:ro \
--name privatebin privatebin-apacheThe container exposes Prometheus-compatible metrics at /metrics endpoint.
Paste Statistics:
privatebin_pastes_total- Total number of pastesprivatebin_pastes_expired- Number of expired pastesprivatebin_pastes_burn_after_reading- Number of burn-after-reading pastesprivatebin_discussions_total- Number of discussions
Format Statistics:
privatebin_pastes_plaintext- Number of plain text pastesprivatebin_pastes_sourcecode- Number of source code pastesprivatebin_pastes_markdown- Number of markdown pastes
Storage Statistics:
privatebin_storage_bytes- Total storage used in bytesprivatebin_storage_files- Total number of files in data directoryprivatebin_storage_average_file_bytes- Average file size in bytes
The metrics endpoint is protected by IP whitelist. Configure allowed IPs using the METRICS_ALLOWED_IPS environment variable:
docker run -d -p 8080:80 \
-e METRICS_ALLOWED_IPS="10.0.1.5 192.168.1.100" \
-v ./data:/srv/privatebin/data \
--name privatebin itefixnet/privatebinNote: Localhost (127.0.0.1) is always allowed. If METRICS_ALLOWED_IPS is not set, the metrics endpoint will be denied to all external requests.
Add to your prometheus.yml:
scrape_configs:
- job_name: 'privatebin'
static_configs:
- targets: ['privatebin-host:8080']
metrics_path: '/metrics'
scrape_interval: 30sA comprehensive set of alert rules is available in prometheus-alerts.yml. Import these rules into your Prometheus configuration to monitor:
Storage Alerts:
- High storage usage warnings (>10GB) and critical alerts (>20GB)
- Rapid storage growth rate detection (>1GB/day)
- Storage capacity forecasting (30-day prediction)
Paste Volume Alerts:
- High paste rate detection (potential abuse)
- No paste activity monitoring
- Expired paste ratio tracking
Service Health:
- Metrics endpoint availability
- Stale metrics detection
To use the alert rules, add to your Prometheus configuration:
rule_files:
- 'prometheus-alerts.yml'All alert thresholds can be customized based on your specific requirements and expected usage patterns.
A pre-built Grafana dashboard is available in grafana-dashboard.json. Import it into Grafana to visualize:
- Paste trends and statistics
- Storage usage and growth
- Format distribution
- Real-time metrics
To import:
- Open Grafana
- Go to Dashboards → Import
- Upload
grafana-dashboard.json - Select your Prometheus data source
- HTTPS: Use a reverse proxy (nginx, Traefik, Caddy) for HTTPS in production
- Data Directory: Ensure proper permissions (770) and ownership
- Updates: Regularly update to the latest PrivateBin version
- Configuration: Review and customize
conf.phpfor your security requirements
For production, use a reverse proxy with HTTPS:
# Run with restart policy and custom network
docker network create proxy
docker run -d \
--name privatebin \
--restart unless-stopped \
--network proxy \
-e TZ=America/New_York \
-e METRICS_ALLOWED_IPS="10.0.1.5" \
-v ./data:/srv/privatebin/data \
-v ./my-conf.php:/srv/privatebin/cfg/conf.php:ro \
itefixnet/privatebinThen configure your reverse proxy (nginx, Traefik, Caddy, etc.) to handle HTTPS and forward to the container.
# Fix data directory permissions
sudo chown -R 33:33 data/
chmod 770 data/docker logs privatebin
# or follow logs
docker logs -f privatebindocker exec privatebin-apache apache2ctl -tThis project is licensed under the BSD 2-Clause License - see the LICENSE file for details.
PrivateBin itself is licensed under the Zlib/libpng license. See the PrivateBin repository for details.
