Docker is powerful, but managing a growing number of containers from the command line gets tedious. Which containers are running? Which volumes are orphaned? What did that container log ten minutes ago? Portainer answers those questions in a browser dashboard, letting you start, stop, inspect and deploy containers with a few clicks.
This guide shows you how to install Portainer Community Edition (CE) on a VPS, keep its web interface secure, and use it to deploy Docker Compose stacks.
What Portainer is (and isn't)
Portainer is a management interface that talks to the Docker engine on your server. With it you can:
- View and control containers, images, networks and volumes
- Read container logs and open a console inside a container
- Deploy and update stacks (Docker Compose files) from the browser
- Manage users and access if several people share the server
- Connect additional Docker hosts to one dashboard
It doesn't replace learning Docker. When something breaks, you'll still want to understand containers, ports and volumes. Our Docker on a VPS guide is a good foundation.
Portainer comes in a free Community Edition and a commercial Business Edition. This guide uses CE.
A security warning before you install
Portainer works by mounting the Docker socket (/var/run/docker.sock). Anyone with access to the Docker socket effectively has root access to the server, because they can start a container that mounts the host's file system. That means your Portainer login is as sensitive as your root password.
Keep that in mind for every decision below: strong password, limited exposure and regular updates.
Step 1: Make sure Docker is installed
You need Docker Engine installed and running:
docker --version
sudo systemctl status docker
If Docker isn't installed, follow the official Docker instructions for your distribution, or our Docker on a VPS guide.
Step 2: Create a volume for Portainer's data
Portainer stores its settings and user accounts in a volume:
docker volume create portainer_data
Step 3: Run the Portainer container
The Portainer documentation provides the current install command and image tag. At the time of writing, a Linux install looks like this:
docker run -d \
-p 127.0.0.1:9443:9443 \
--name portainer \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:lts
Note two differences from the commonly copied command:
127.0.0.1:9443:9443publishes the HTTPS UI only on localhost. The official example publishes on all interfaces; that is convenient but exposes the login page to the whole internet.- Port 8000 is omitted. It's used by Portainer's Edge Agent feature for connecting remote environments. If you aren't using Edge Agents, you don't need it.
Check the docs for the current recommended tag before installing, since Portainer publishes both long-term support and short-term releases.
The Docker firewall trap
Many people install UFW, block everything except SSH, publish a container on 0.0.0.0, and assume the firewall protects it. It often doesn't. Docker writes its own iptables rules for published ports, and those rules can take effect before UFW's rules, so the port ends up reachable from the internet anyway.
The simplest defenses are:
- Publish admin interfaces on
127.0.0.1only, as above. - Put public services behind a reverse proxy on ports 80/443.
- Verify from another machine with a port check (for example
nc -zv your-server-ip 9443) rather than trusting your firewall rules.
Step 4: Reach the dashboard securely
Since the UI listens only on localhost, use an SSH tunnel from your computer:
ssh -L 9443:127.0.0.1:9443 user@your-server-ip
Leave that session open and visit https://localhost:9443 in your browser. Portainer uses a self-signed certificate by default, so your browser will show a warning; for a tunnel to your own server this is expected.
If you'd rather use a domain, put Portainer behind Nginx with a Let's Encrypt certificate (see our Certbot guide), and consider restricting access by IP address. Make sure the proxy passes WebSocket headers, because Portainer's container console uses them.
Step 5: Create the admin account quickly
On first launch, Portainer asks you to create an administrator account. For security, Portainer only waits a short time for this; if you take too long, it stops and asks you to restart the container:
docker restart portainer
Choose a long, unique password and store it in a password manager. Then select the local Docker environment to start managing your containers.
Step 6: Deploy a stack
Stacks are Portainer's interface for Docker Compose. To deploy one:
- Go to Stacks > Add stack.
- Name it, for example
uptime. - Paste a Compose file in the web editor, upload one, or point Portainer at a Git repository.
- Add environment variables in the form instead of hard-coding secrets in the file.
- Click Deploy the stack.
Deploying from a Git repository is especially useful: your Compose files stay version-controlled, and you can redeploy after pushing changes. Self-hosted tools such as Uptime Kuma and Plausible Analytics are good candidates for managing this way.
One caveat: stacks created in Portainer are managed by Portainer. Stacks you started with docker compose on the command line will appear, but Portainer has limited control over them. Pick one method per stack to avoid confusion.
Everyday tasks in Portainer
- Logs: open a container and click Logs to see recent output, with search and auto-refresh.
- Console: Console opens a shell inside a running container, handy for quick checks.
- Stats: see live CPU, memory and network usage per container.
- Cleanup: the Images and Volumes pages show unused items you can remove to reclaim disk space. Double-check before deleting volumes, because they hold data.
- Recreate with a fresh image: pull the latest image and recreate a container in one step.
Updating Portainer
To update Portainer itself, pull the new image and recreate the container. Your settings live in the portainer_data volume, so they survive:
docker pull portainer/portainer-ce:lts
docker stop portainer && docker rm portainer
# re-run the docker run command from Step 3
Read the release notes before upgrading across major versions.
Back up the important parts
Portainer's own data volume holds your users and settings, but the real value on the server is your application data in other volumes. Back up both, and keep copies off the server following the 3-2-1 backup rule.
Wrapping up
Portainer turns Docker management into a clear, browser-based dashboard, which is a big time-saver once you run more than a few containers. Install it with the official command, bind the UI to localhost, reach it over an SSH tunnel or a locked-down proxy, create the admin account right away, and remember that Portainer access means root access. Handled that way, it's one of the most useful tools you can add to a self-hosted VPS.