متقدم
البحث فيأدلة التثبيت
طريقة البحث
  • الصق رسالة الخطأ بين علامتي تنصيص، مثل "permission denied"، لتجد جدول الحل.
  • اختر مجالًا وجزءًا من الدليل (التثبيت، أول الإعدادات، الاستخدام اليومي، الأمان، الحلول) لتصل مباشرة إلى الخطوة الصحيحة.
  • "كلمتان" تجد العبارة بالضبط.
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث
جرّب:

الدليل 93Portainer · Containers

Install and set up Portainer (web UI for Docker and Kubernetes)

Portainer is a web UI to manage containers: Docker hosts, Docker Swarm and Kubernetes clusters. You see containers, images, volumes, networks and logs, deploy Compose stacks from Git, and give teams limited access — useful for small teams, labs, and people who are not yet comfortable with the command line. This guide installs Portainer CE with Docker behind HTTPS, secures the first login, adds more hosts with the agent, deploys a stack from Git, and covers backups and fixes.

  • 10 الدروس
  • 5 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

93.1

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.

ItemValue
Imageportainer/portainer-ce (use the lts tag) — Business Edition portainer-ee has more RBAC features
Data/data volume (database, settings, TLS)
Ports9443 (HTTPS UI), 8000 (Edge agent tunnel, only if used); agent: 9001
NeedsDocker Engine or Podman (or a Kubernetes cluster)

انتبه

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.

93.2

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 -3

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

93.3

First configuration: the settings to make first

WhereSettingWhy
First pageAdmin user with a long passwordFull control of all hosts.
Settings → AuthenticationPassword rules; OAuth/LDAP (if available in your edition)No shared admin.
Users / TeamsPersonal users; teams with access only to their environmentsLeast privilege.
Settings → GeneralSession lifetime short (for example 8 h)Stolen sessions expire.
Environments → local → SecurityDisable bind mounts / privileged mode for non-adminsUsers can not escape to the host.
Settings → SSL certificateYour own certificate (or Nginx in front)No browser warnings, real HTTPS.

93.4

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 --reload

In 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).

93.5

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.

deploy/compose.yaml
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.

93.6

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.

93.7

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 the lts tag and update regularly.
  • Remember: Portainer admin = root on every connected host.

93.8

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

Data stays in the portainer_data volume. Update agents to the same version.

الأوامر في هذا الدرس

93.9

Fix common problems

ProblemCauseFix
"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 streamWebSocket not proxied.Add Upgrade/Connection headers in Nginx.
Stack update from Git failsGit 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.

الأوامر في هذا الدرس

93.10

Next steps

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

كل الأوامر في هذا الفصل