Prerequisites
Before starting, ensure you have:
Server Requirements
- • RamNode VPS (1GB+ RAM, 2GB recommended)
- • Ubuntu 20.04 or 22.04 LTS
- • Root or sudo access
- • SSH client
Optional Requirements
- • Domain name pointed to VPS
- • Basic command line familiarity
- • Understanding of Docker concepts
Initial VPS Setup
Connect to your RamNode VPS and update the system:
ssh root@your-vps-ipapt update && apt upgrade -y💡 Tip: Replace "your-vps-ip" with your actual RamNode VPS IP address.
Configure Firewall
Set up a basic firewall configuration:
# Allow SSH (adjust port if you've changed it)
ufw allow 22/tcp
# Allow HTTP and HTTPS
ufw allow 80/tcp
ufw allow 443/tcp
# Allow Portainer (we'll use port 9443 for HTTPS)
ufw allow 9443/tcp
# Enable firewall
ufw --force enable⚠️ Warning: Make sure SSH is allowed before enabling UFW to avoid losing access!
Install Docker
Install Docker using the official installation script:
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.shsystemctl start docker
systemctl enable dockerusermod -aG docker $USERdocker --version
docker run hello-world✅ Docker is now installed and ready for Portainer deployment.
Create Docker Volumes
Create persistent volumes for Portainer data:
docker volume create portainer_data📦 This volume will store all Portainer configuration and data persistently.
Deploy Portainer
Choose between HTTP (for testing) or HTTPS (for production) deployment:
Option A: HTTP Deployment (Development/Testing)
docker run -d \
--name portainer \
--restart unless-stopped \
-p 8000:8000 \
-p 9000:9000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:latestAccess at: http://your-vps-ip:9000
Option B: HTTPS Deployment (Recommended for Production)
First, generate a self-signed certificate:
mkdir -p /opt/portainer/certs
cd /opt/portainer/certs
openssl genrsa -out portainer.key 2048
openssl req -new -x509 -key portainer.key -out portainer.crt -days 365Then deploy Portainer with HTTPS:
docker run -d \
--name portainer \
--restart unless-stopped \
-p 8000:8000 \
-p 9443:9443 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
-v /opt/portainer/certs:/certs \
portainer/portainer-ce:latest \
--ssl --sslcert /certs/portainer.crt --sslkey /certs/portainer.keyAccess at: https://your-vps-ip:9443
Initial Portainer Configuration
Complete the initial setup through the web interface:
1. Open Web Browser
Navigate to your Portainer instance:
- • HTTP: http://your-vps-ip:9000
- • HTTPS: https://your-vps-ip:9443
2. Create Admin Account
- • Username: Choose a secure username
- • Password: Use a strong password (minimum 12 characters)
3. Select Environment
- • Select "Docker" as your environment type
- • Choose "Local" to manage the local Docker environment
🎉 Portainer is now ready to use! You can start managing your Docker containers.
Configure Reverse Proxy (Optional)
For a more professional setup, configure NGINX as a reverse proxy:
apt install -y nginxnano /etc/nginx/sites-available/portainerserver {
listen 80;
server_name your-domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name your-domain.com;
ssl_certificate /path/to/your/certificate.crt;
ssl_certificate_key /path/to/your/private.key;
# Modern SSL configuration
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512;
ssl_prefer_server_ciphers off;
location / {
proxy_pass https://localhost:9443;
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;
proxy_ssl_verify off;
}
}ln -s /etc/nginx/sites-available/portainer /etc/nginx/sites-enabled/
nginx -t
systemctl restart nginxSecurity Hardening
Implement additional security measures:
Enable Docker Content Trust:
export DOCKER_CONTENT_TRUST=1
echo 'export DOCKER_CONTENT_TRUST=1' >> ~/.bashrcConfigure Fail2Ban for Portainer:
cat > /etc/fail2ban/filter.d/portainer.conf << 'EOF'
[Definition]
failregex = ^.*Invalid credentials.*client_ip=<HOST>.*$
ignoreregex =
EOFcat >> /etc/fail2ban/jail.local << 'EOF'
[portainer]
enabled = true
port = 9000,9443
protocol = tcp
filter = portainer
logpath = /var/lib/docker/containers/*/portainer*-json.log
maxretry = 3
bantime = 3600
findtime = 600
EOFsystemctl restart fail2ban🔐 Security Tip: Use strong passwords, enable two-factor authentication when available, and regularly update Docker and Portainer.
Backup Strategy
Create an automated backup script for Portainer data:
cat > /opt/backup-portainer.sh << 'EOF'
#!/bin/bash
BACKUP_DIR="/opt/backups"
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_FILE="portainer_backup_${DATE}.tar.gz"
mkdir -p $BACKUP_DIR
# Stop Portainer container
docker stop portainer
# Create backup
docker run --rm \
-v portainer_data:/data:ro \
-v $BACKUP_DIR:/backup \
ubuntu:latest \
tar -czf /backup/$BACKUP_FILE -C /data .
# Start Portainer container
docker start portainer
echo "Backup completed: $BACKUP_DIR/$BACKUP_FILE"
# Clean up old backups (keep last 7 days)
find $BACKUP_DIR -name "portainer_backup_*.tar.gz" -mtime +7 -delete
EOF
chmod +x /opt/backup-portainer.shecho "0 2 * * * /opt/backup-portainer.sh" | crontab -💾 Backups will now run automatically at 2:00 AM daily, keeping the last 7 days of backups.
Monitoring and Maintenance
Keep your Portainer installation healthy and up to date:
Check Portainer status:
docker ps | grep portainer
docker logs portainerUpdate Portainer:
# Pull the latest image
docker pull portainer/portainer-ce:latest
# Stop and remove current container
docker stop portainer
docker rm portainer
# Deploy updated container (use your preferred deployment command from Step 6)Monitor resource usage:
# Check system resources
htop
df -h
docker system dfTroubleshooting
Common issues and their solutions:
Portainer Won't Start
docker logs portainerls -la /var/lib/docker/volumes/portainer_data/Can't Access Web Interface
docker psufw statusnetstat -tlnp | grep :9443SSL Certificate Issues
cd /opt/portainer/certs
rm portainer.*
openssl req -newkey rsa:2048 -nodes -keyout portainer.key -x509 -days 365 -out portainer.crt -subj "/CN=your-domain.com"
docker restart portainerBest Practices
- • Regular Updates: Keep Docker and Portainer updated regularly
- • Backup Strategy: Implement automated backups of Portainer data
- • Security: Use strong passwords and enable two-factor authentication when available
- • Monitoring: Set up monitoring for container health and resource usage
- • Documentation: Document your container configurations and deployment procedures
- • Testing: Test backup and recovery procedures regularly
🎉 Congratulations!
You now have a fully functional Portainer installation on your RamNode VPS! This setup provides you with a powerful platform for managing Docker containers through an intuitive web interface.
Next Steps
- • Explore Portainer's features like user management and registry management
- • Use application templates for quick container deployments
- • Set up monitoring for container health and resource usage
- • Configure role-based access control for team members
- • Integrate with Docker registries for custom images
- • Explore Portainer's API for automation possibilities
