Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

What Portainer Is

Portainer shows the containers on a server in a browser: you can start and stop them, read logs, open a console, deploy Compose files as stacks, and manage volumes and networks. The Community Edition is open-source and installs as one container. It talks to Docker through the Docker socket, and access to that socket is equal to root access on the server. Treat the Portainer login like the root password.

Before You Start

  • Docker installed: see how to install Docker on Ubuntu or on Debian.
  • A plan for access: the interface must not be open to the internet. The steps below bind it to 127.0.0.1, and you reach it through SSH.
  • Five quiet minutes: you create the admin account right after the first start.

Step 1: Create the Data Volume

docker volume create portainer_data

Portainer keeps its settings, users, and stack files in this volume, mounted at /data. The volume survives updates of the container.

Step 2: Run the Container

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

Port 9443 serves the interface over HTTPS with a self-signed certificate. It is bound to 127.0.0.1 on purpose: a port that Docker publishes on all addresses is reachable from the internet even when UFW blocks it, and firewalld does not stop it either, as explained in Docker port mapping. Check that it runs with docker ps and docker logs portainer.

Step 3: Open It through an SSH Tunnel

On your own computer, open a tunnel and keep the terminal open:

ssh -L 9443:127.0.0.1:9443 user@your_server_ip

Then browse to https://localhost:9443. Your browser warns about the self-signed certificate; that is expected for this local connection. Tunnels are covered in SSH port forwarding.

Step 4: Create the Admin Account at Once

Current releases first ask for a setup token. It is printed in the container's log; find the line that contains setup_token=:

docker logs portainer

The next page creates the first administrator. The user name field is filled in for you; change it to a name of your own, and choose a long, unique password (Portainer requires at least 12 characters). For security, a new instance stops after 5 minutes if the setup is not finished, so that nobody else can take it over. If that happens, run docker stop portainer and docker start portainer, read the new token from the log, and finish the setup at once. Portainer then detects the local Docker environment and adds it.

Ports Portainer Uses

PortPurpose
9443Web interface, HTTPS
9000Plain HTTP, legacy, optional
8000Tunnel for Edge agents

Publish only 9443 for a single server. The official install command also publishes 8000 on all addresses; it is needed only when you manage remote servers through Edge agents, so it is left out above. Port 9000 is not published unless you add it, and it would send the login without encryption.

Optional: A Reverse Proxy with HTTPS

If several people need access without SSH, put Nginx in front with a real certificate and limit it to known addresses:

server {
    server_name portainer.example.com;
    allow 203.0.113.10;
    deny all;
    location / {
        proxy_pass https://127.0.0.1:9443;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

The Upgrade headers keep the container console working. Test with sudo nginx -t before reloading, and add the certificate as in Certbot Nginx. The general setup is in Nginx reverse proxy.

Update Portainer

Back up first: export a backup from Portainer's settings or take a server snapshot. Then replace the container; the volume keeps the data:

docker pull portainer/portainer-ce:lts
docker stop portainer
docker rm portainer

Run the command from Step 2 again, unchanged. The general method is in how to update a Docker container.

Troubleshooting

  • The page does not load: check that the tunnel terminal is still open and that docker ps shows the container.
  • The setup page says the instance timed out: stop and start the container, then finish the setup within 5 minutes.
  • No local environment: the socket was not mounted; check the -v /var/run/docker.sock line.
Was this answer helpful?
Loading...