Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
Know it before you install
The Portainer server runs as a container with a small database. It manages environments: the local Docker (through the socket), remote Docker hosts (through the Portainer agent or Edge agent) and Kubernetes clusters. Stacks are Docker Compose files that Portainer deploys and can update from Git.
| Item | Value |
|---|---|
| Image | portainer/portainer-ce (use the lts tag) — Business Edition portainer-ee has more RBAC features |
| Data | /data volume (database, settings, TLS) |
| Ports | 9443 (HTTPS UI), 8000 (Edge agent tunnel, only if used); agent: 9001 |
| Needs | Docker Engine or Podman (or a Kubernetes cluster) |
Let op
Portainer has the Docker socket — that is root on the host. Anyone who can log in to Portainer as admin controls the server. Protect it like SSH.
Install with Docker (RHEL and Ubuntu)
Install Docker first (see the Docker guide), then:
docker volume create portainer_data
docker run -d --name portainer --restart=always -p 127.0.0.1:9443:9443 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:lts
docker logs portainer | tail -3Open https://127.0.0.1:9443 through an SSH tunnel (ssh -L 9443:127.0.0.1:9443 host1) — or put Nginx with a real certificate in front (WebSocket headers needed). Create the admin user within 5 minutes (a long password); after that, Portainer locks the setup for safety.
First configuration: the settings to make first
| Where | Setting | Why |
|---|---|---|
| First page | Admin user with a long password | Full control of all hosts. |
| Settings → Authentication | Password rules; OAuth/LDAP (if available in your edition) | No shared admin. |
| Users / Teams | Personal users; teams with access only to their environments | Least privilege. |
| Settings → General | Session lifetime short (for example 8 h) | Stolen sessions expire. |
| Environments → local → Security | Disable bind mounts / privileged mode for non-admins | Users can not escape to the host. |
| Settings → SSL certificate | Your own certificate (or Nginx in front) | No browser warnings, real HTTPS. |
Add more Docker hosts with the agent
On each extra host (agent listens on 9001 — allow only the Portainer server):
docker run -d --name portainer_agent --restart=always -p 9001:9001 -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes portainer/agent:lts
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.10" port port="9001" protocol="tcp" accept'
firewall-cmd --reloadIn Portainer: Environments → Add environment → Docker Standalone → Agent, address host2.corp.example.com:9001. For hosts behind NAT or at remote sites use the Edge agent (it connects out to Portainer). For Kubernetes, add the cluster with the Portainer agent manifest or Helm (from the same page).
Deploy a stack from Git
Stacks → Add stack → Repository: the Git URL, branch main, compose path deploy/compose.yaml, and GitOps updates (polling or webhook). Environment variables (passwords) are set in Portainer, not in Git.
services:
web:
image: registry.example.com/shop/web:1.4.0
restart: unless-stopped
ports: ["127.0.0.1:8080:80"]
environment:
DB_PASSWORD: ${DB_PASSWORD}A new commit with a new image tag → Portainer updates the stack.
Daily use: the real uses
- Containers: logs, stats, console (shell), restart, recreate with a new image.
- Images: pull, remove unused; Volumes: see what uses space.
- Stacks: deploy, update from Git, roll back to the previous file.
- Templates: one-click apps for labs.
docker logs --tail 50 portainer
docker exec portainer ls /data
docker stop portainer && docker run --rm -v portainer_data:/data -v "$PWD":/backup alpine tar czf /backup/portainer-$(date +%F).tgz -C /data . && docker start portainer(Settings → Backup Portainer also makes a backup file from the UI.)
Real uses at work:
- Small teams and labs that run Compose apps on a few hosts.
- Give developers limited access (logs, restart) to their own environments without SSH.
- A visual overview of many Docker hosts and edge devices.
Make it safe
Security checklist:
- Only HTTPS; the UI not public (VPN/admin network or SSO in front).
- Strong admin password, personal users, teams with least privilege; short sessions.
- Agent port 9001 only from the Portainer server; Edge port 8000 only if you use Edge.
- Turn off bind mounts / privileged containers for non-admin users.
- Back up
/data; pin theltstag and update regularly. - Remember: Portainer admin = root on every connected host.
Update and remove
docker pull portainer/portainer-ce:lts
docker stop portainer && docker rm portainer
docker run -d --name portainer --restart=always -p 127.0.0.1:9443:9443 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:ltsData stays in the portainer_data volume. Update agents to the same version.
Fix common problems
| Problem | Cause | Fix |
|---|---|---|
| "Your Portainer instance timed out for security purposes" | The admin was not created within 5 minutes. | docker restart portainer, then create the admin at once. |
| Forgot the admin password | — | Stop Portainer and use Portainer's password reset helper image on the data volume (see the Portainer docs). |
| Agent environment "unreachable" | Firewall, wrong address, or version mismatch. | Open 9001 from the server; same version for server and agent. |
| UI loads but consoles/logs do not stream | WebSocket not proxied. | Add Upgrade/Connection headers in Nginx. |
| Stack update from Git fails | Git credentials or compose errors. | Check the Git credentials in the stack; test the compose file with docker compose config. |
permission denied on the Docker socket (Podman/SELinux) | Socket path or SELinux label. | Use the Podman socket path; run with --privileged only if the docs for your setup say so. |
Next steps
- What it manages: Docker, Podman, Kubernetes.
- The command-line way for Kubernetes: k9s. GitOps for Kubernetes: Argo CD.
- HTTPS in front: Nginx, Traefik.
1Why is a Portainer admin account as powerful as root?
Portainer controls Docker through the socket, and Docker can mount the host's file system.
2The setup page says it timed out. What do you do?
Restart the Portainer container and create the admin user right away (within 5 minutes).