This guide walks you through installing Docker on a VPS, deploying Portainer CE (Community Edition) as a container, accessing it securely over HTTPS, and keeping both Docker and Portainer up to date. By the end, you’ll have a web-based dashboard to manage containers, images, volumes, and networks from any browser.
What You’ll Need
- A VPS running a recent Linux distribution (Ubuntu 22.04/24.04, Debian 12, or similar) with root or sudo access.
- A domain name pointing to your VPS’s IP address (for free HTTPS via Let’s Encrypt). If you don’t have one, you can use a self-signed certificate or skip HTTPS for testing.
- Open ports 80 and 443 in your firewall (if enabled) for web traffic.
- SSH client (like PuTTY on Windows, or Terminal on macOS/Linux) to connect to your server.
- Basic comfort with the command line.
Step-by-Step
- Connect to your VPS via SSH:
ssh user@your-server-ip. - Update the system: run
sudo apt update && sudo apt upgrade -y(for Debian/Ubuntu). Reboot if the kernel was updated. - Install Docker using the official convenience script (recommended for beginners):
curl -fsSL https://get.docker.com -o get-docker.shthensudo sh get-docker.sh. Verify withdocker --version. - Enable Docker to start on boot:
sudo systemctl enable docker. - Create a persistent volume for Portainer data:
sudo docker volume create portainer_data. This ensures your configuration survives container updates and restarts. - Install Portainer CE (the free version) by running the following command. Replace
your-domain.comwith your actual domain (or your VPS IP if you’re not using a domain):sudo docker run -d --name portainer --restart=always -p 8000:8000 -p 9443:9443 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
This maps port 8000 (for Edge agent connections) and port 9443 (for the HTTPS web UI). - Verify the container is running:
sudo docker psshould showportainerwith statusUp. - Access the web UI: open
https://your-server-ip:9443in your browser. You’ll see a security warning because the default certificate is self-signed. Click through to proceed (this is expected at this stage). - Complete the initial setup: create a strong admin username and password (at least 12 characters). Choose “Get Started” to manage the local Docker environment.
- Set up HTTPS with a trusted certificate (recommended):
- Stop the Portainer container:
sudo docker stop portainer. - Install Nginx as a reverse proxy:
sudo apt install nginx. - Create an Nginx config file:
sudo nano /etc/nginx/sites-available/portainerand paste the following (replaceyour-domain.com):server { listen 80; server_name your-domain.com; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name your-domain.com; ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem; 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; } } - Enable the site:
sudo ln -s /etc/nginx/sites-available/portainer /etc/nginx/sites-enabled/and remove the default:sudo rm /etc/nginx/sites-enabled/default. - Install Certbot for Let’s Encrypt:
sudo apt install certbot python3-certbot-nginx. - Obtain a certificate:
sudo certbot --nginx -d your-domain.com. Follow the prompts. - Test the Nginx config:
sudo nginx -t, then reload:sudo systemctl reload nginx. - Start Portainer again:
sudo docker start portainer.
- Stop the Portainer container:
- Access Portainer via your domain: now visit
https://your-domain.com– you should see the login page with a valid lock icon. - Keep Docker and Portainer updated:
- Update Docker Engine:
sudo apt update && sudo apt upgrade -y(this updates Docker along with other system packages). - Update Portainer: pull the latest image and recreate the container:
sudo docker stop portainer sudo docker rm portainer sudo docker pull portainer/portainer-ce:latest sudo docker run -d --name portainer --restart=always -p 8000:8000 -p 9443:9443 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
- Update Docker Engine:
- Enable automatic updates (optional but recommended): use a tool like Watchtower to keep Portainer (and other containers) updated automatically. Install with:
sudo docker run -d --name watchtower --restart=always -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower. This checks for updates daily and recreates containers with the same settings.
Common Mistakes
- Forgetting to mount the Docker socket: without
-v /var/run/docker.sock:/var/run/docker.sock, Portainer cannot communicate with Docker and will show “Unable to connect to Docker”. - Using the wrong data volume: if you don’t create and reuse a named volume, Portainer loses its configuration when you update the container.
- Opening the wrong ports: the web UI runs on 9443 (HTTPS) and 8000 (Edge). If you only open port 9000 (the old HTTP port), you won’t reach the UI.
- Skipping the firewall: if you have UFW or another firewall, you must allow ports 80, 443, 8000, and 9443:
sudo ufw allow 80,443,8000,9443/tcp. - Not setting a strong admin password: Portainer is a powerful admin tool; a weak password can compromise your entire server.
- Leaving the default self-signed certificate: browsers will keep showing warnings; using a reverse proxy with Let’s Encrypt solves this cleanly.
Tips
- Use a dedicated subdomain like
portainer.example.comso you can later add other services without conflicts. - Back up the
portainer_datavolume regularly:sudo tar -czf portainer_backup.tar.gz -C /var/lib/docker/volumes/portainer_data/_data . - Enable two-factor authentication (2FA) in Portainer’s settings for extra security.
- Restrict access to Portainer by IP address using Nginx’s
allowanddenydirectives if you’re the only user. - Use the Portainer API for automation – it’s well-documented and can integrate with CI/CD pipelines.
- For production, consider running Portainer itself in a Docker Swarm or Kubernetes cluster for high availability.
Troubleshooting
- Can’t access the web UI: check that the container is running (
sudo docker ps), that ports 9443 and 8000 are listening (sudo ss -tulpn | grep -E '9443|8000'), and that your firewall allows them. - Browser shows “This site can’t be reached”: verify your VPS IP and that the domain resolves correctly (if using one). Try accessing via IP first.
- Security warning persists: if you used the reverse proxy, make sure Nginx is actually serving the certificate. Check with
sudo certbot certificatesand that the Nginx config paths match. - Portainer says “Unable to connect to Docker”: ensure the Docker socket is mounted correctly. Recreate the container with the exact
-v /var/run/docker.sock:/var/run/docker.sockflag. - Portainer won’t start after update: check logs with
sudo docker logs portainer. If the data volume is corrupted, restore from backup. - Nginx returns 502 Bad Gateway: the proxy can’t reach Portainer. Make sure Portainer is running and that
proxy_passpoints tohttps://localhost:9443(nothttp).
Frequently Asked Questions
Is Portainer free?
Yes, Portainer Community Edition (CE) is free and open-source. There’s also a Business Edition with extra features like RBAC and registry management, but CE is sufficient for most personal and small-team use.
Do I need to install Docker separately?
Yes, Portainer runs as a Docker container, so Docker must be installed first. The steps above cover installing Docker on a Linux VPS.
Can I use Portainer to manage multiple servers?
Yes, you can add remote environments in Portainer using the Edge agent or by exposing the Docker API over TLS. The free CE version supports multiple environments, but some advanced features require Business Edition.
How do I update Portainer without losing my settings?
As long as you use the same named volume (portainer_data), your settings and configurations persist. Just pull the new image and recreate the container with the same volume.
Is it safe to expose Portainer to the internet?
It’s risky if you don’t secure it properly. Always use HTTPS, a strong password, and consider enabling 2FA. For extra safety, restrict access by IP or use a VPN.
What is the default port for Portainer?
Portainer CE uses port 9443 for the HTTPS web UI and port 8000 for Edge agent connections. Older versions used port 9000 for HTTP, but that is deprecated.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Secure Boot Battlefield 6 ASUS: Fix & Enable Guide
- Best Tech Websites to Follow for Pros & Beginners
- Second Wind Quest Walkthrough: Where Winds Meet6.00 min/km
- Enshrouded Weapon Upgrade Guide: How to Improve Gear5.00 min/km
- Connect Phone to Controller for Cloud Gaming
- Python Search Highlighting: Snippets & Matches