Docker Management

    Deploy Portainer on RamNode VPS

    Portainer is a powerful, lightweight management UI for Docker that makes container management accessible through an intuitive web interface. Deploy it on RamNode's reliable VPS platform for effortless Docker container management.

    Ubuntu 20.04/22.04
    Docker + Portainer
    ⏱️ 20-30 minutes

    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
    2

    Initial VPS Setup

    Connect to your RamNode VPS and update the system:

    Connect via SSH
    ssh root@your-vps-ip
    Update System Packages
    apt update && apt upgrade -y

    💡 Tip: Replace "your-vps-ip" with your actual RamNode VPS IP address.

    3

    Configure Firewall

    Set up a basic firewall configuration:

    UFW Firewall Setup
    # 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!

    4

    Install Docker

    Install Docker using the official installation script:

    Install Docker
    curl -fsSL https://get.docker.com -o get-docker.sh
    sh get-docker.sh
    Start and Enable Docker
    systemctl start docker
    systemctl enable docker
    Add User to Docker Group (if not using root)
    usermod -aG docker $USER
    Verify Docker Installation
    docker --version
    docker run hello-world

    ✅ Docker is now installed and ready for Portainer deployment.

    5

    Create Docker Volumes

    Create persistent volumes for Portainer data:

    Create Volume
    docker volume create portainer_data

    📦 This volume will store all Portainer configuration and data persistently.

    6

    Deploy Portainer

    Choose between HTTP (for testing) or HTTPS (for production) deployment:

    Option A: HTTP Deployment (Development/Testing)

    Deploy Portainer with HTTP
    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:latest

    Access at: http://your-vps-ip:9000

    Option B: HTTPS Deployment (Recommended for Production)

    First, generate a self-signed certificate:

    Generate SSL 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 365

    Then deploy Portainer with HTTPS:

    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.key

    Access at: https://your-vps-ip:9443

    7

    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.

    8

    Configure Reverse Proxy (Optional)

    For a more professional setup, configure NGINX as a reverse proxy:

    Install NGINX
    apt install -y nginx
    Create NGINX Configuration
    nano /etc/nginx/sites-available/portainer
    NGINX Configuration File
    server {
        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;
        }
    }
    Enable Site and Restart NGINX
    ln -s /etc/nginx/sites-available/portainer /etc/nginx/sites-enabled/
    nginx -t
    systemctl restart nginx
    9

    Security Hardening

    Implement additional security measures:

    Enable Docker Content Trust:

    Enable Content Trust
    export DOCKER_CONTENT_TRUST=1
    echo 'export DOCKER_CONTENT_TRUST=1' >> ~/.bashrc

    Configure Fail2Ban for Portainer:

    Create Fail2Ban Filter
    cat > /etc/fail2ban/filter.d/portainer.conf << 'EOF'
    [Definition]
    failregex = ^.*Invalid credentials.*client_ip=<HOST>.*$
    ignoreregex =
    EOF
    Add Portainer Jail
    cat >> /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
    EOF
    Restart Fail2Ban
    systemctl restart fail2ban

    🔐 Security Tip: Use strong passwords, enable two-factor authentication when available, and regularly update Docker and Portainer.

    10

    Backup Strategy

    Create an automated backup script for Portainer data:

    Create Backup Script
    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.sh
    Schedule Daily Backups
    echo "0 2 * * * /opt/backup-portainer.sh" | crontab -

    💾 Backups will now run automatically at 2:00 AM daily, keeping the last 7 days of backups.

    11

    Monitoring and Maintenance

    Keep your Portainer installation healthy and up to date:

    Check Portainer status:

    Status Commands
    docker ps | grep portainer
    docker logs portainer

    Update Portainer:

    Update 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:

    Resource Monitoring
    # Check system resources
    htop
    df -h
    docker system df
    12

    Troubleshooting

    Common issues and their solutions:

    Portainer Won't Start

    Check Logs
    docker logs portainer
    Verify Volume Permissions
    ls -la /var/lib/docker/volumes/portainer_data/

    Can't Access Web Interface

    Check Container Status
    docker ps
    Verify Firewall Rules
    ufw status
    Test Port Connectivity
    netstat -tlnp | grep :9443

    SSL Certificate Issues

    Regenerate Certificates
    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 portainer

    Best 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