Skip to content

Set Up Portainer on a Linux Server – Manage Docker Containers in Your Browser

Set up Portainer on your Linux server as a One-Click App with HTTPS or manually with Docker Compose. Manage containers, stacks, and logs easily in your browser.

27 November 202611 min read1 Views0 helpful

Introduction

Portainer is a web interface for Docker. Instead of typing every command into the terminal, you can see all your server’s containers, images, volumes, and networks in your browser, read logs, open a console inside a container, and start entire applications as a stack from a Compose file. In this guide, we’ll show you two ways to do this: the easy way, as a One-Click App, which makes Portainer Community Edition (CE) available over HTTPS in just a few clicks, and the manual installation with Docker Compose, where you set up the firewall and HTTPS yourself. You’ll also learn why Portainer needs access to the Docker socket and what that means for your server’s security.

When Portainer makes sense on a VPS

Portainer isn’t a service for visitors; it’s a management tool. It’s a good fit for a VPS if:

  • You run multiple containers and want to keep track of them: view their status, resource usage, ports, and volumes at a glance.
  • You need logs and a console in your browser, for example, to quickly check why a container keeps restarting without logging in over SSH.
  • You want to start applications from Compose files that you can edit and save in Portainer, then deploy again later.
  • You manage multiple Docker servers centrally by connecting additional servers through the Portainer Agent.

Portainer is less useful if your server only runs a single container that you rarely touch. In that case, the docker compose command line is faster, and you avoid adding another interface with full access to your server.

The easy way: Portainer as a One-Click App

The quickest way to get Portainer is through your VPS’s One-Click Apps. The app installs Portainer CE using the LTS version, makes it directly accessible over HTTPS with a domain, and automatically connects to Docker on your VPS the first time it starts. You don’t need to set up a reverse proxy, certificate, or firewall rules.

Requirements

  • A Linux VPS (Debian or Ubuntu) with One-Click Apps set up. See Set up One-Click Apps for instructions.
  • SSH access (see SSH). You’ll need it once when you first log in to read the setup token from the logs.

Install

  1. Open your VPS in the ZapX dashboard and switch to the One-Click Apps tab.
  2. Find Portainer in the app catalog and click Install app.
  3. Use a custom subdomain or zap.cloud is already selected with a random name. Leave this option enabled or enter a name of your own: you’ll use the domain to access Portainer over HTTPS.
  4. Portainer has no other required fields. You won’t set a password in the form; you’ll do that the first time you open Portainer.
  5. Click Queue installation. Portainer will be ready in one or two minutes.
Warning

You have 5 minutes after startup Portainer requires you to create the administrator account within 5 minutes of startup. So, display the setup token right after installation and create the account immediately. Once the time has expired, Portainer won’t accept any setup attempts. If that happens, restart the app from its app card and read the token from the logs again. Always use the most recently issued line.

First login with a setup token

Since version 2.43, Portainer requires a one-time setup token during setup. This prevents someone else who knows the address from creating the administrator account before you do. The token is only available in the container logs. Connect to your VPS over SSH and run:

Code
docker logs $(docker ps -q --filter name=portainer) 2>&1 | grep setup_token

Copy the value after setup_token=. Then open the app’s Access link. Portainer displays the “New Portainer installation” page:

  1. The Username field is already set to admin. You can change the name.
  2. Enter a password of at least 12 characters under Password and Confirm password.
  3. Paste the token you copied into Setup token and click Create user.
  4. Skip the “Set up Edge Compute” step by clicking Skip. You only need Edge Compute for remote devices that use the Edge Agent.
  5. In the Environment Wizard, click Get Started. This uses the local environment, which is Docker on your VPS.

You create the login details yourself. Portainer doesn’t have any automatically generated values under App environment in the app settings (gear icon), so the panel doesn’t know your password. Save it in your password manager right away.

What Portainer can see on your VPS

The local environment appears under Home. When you click it, you’ll see more than just Portainer: you’ll see all containers on your VPS, including your other One-Click Apps and the containers that run the One-Click Apps themselves, such as coolify, coolify-proxy, coolify-db, and coolify-redis.

Warning

Don’t modify One-Click App containers in Portainer Don’t stop, delete, or edit the coolify containers or the containers for your One-Click Apps in Portainer. One-Click Apps manage these containers themselves. Changes made in Portainer may be overwritten the next time an app restarts or updates, or, in the worst case, may prevent your apps from being managed. Always start, stop, and update One-Click Apps in the dashboard. Portainer is useful for viewing logs and resource usage and for running your own stacks.

Updates and backups

Update Portainer from the app settings (gear icon) under App update. Click Check for updates, then install a new version with Apply update. If the page says the app is up to date, there isn’t a newer version in the app catalog yet. You can ignore the “New version available” message in the bottom-left corner of Portainer in that case; Portainer doesn’t update itself.

Your users, settings, and stacks are stored in a separate volume and are retained during updates. You can also download a backup of your Portainer settings under Settings, in the Back up Portainer section, by clicking Download backup. This doesn’t include your container data, which is stored in each container’s own volumes.

Manual installation

The rest of this guide covers the manual installation of Portainer CE with Docker Compose on your VPS. For example, you might use this method if you don’t use One-Click Apps on your server or want to configure every step yourself.

Requirements

  • A Linux VPS running Debian or Ubuntu, with SSH access. See First access via SSH.
  • Docker and Docker Compose. See Install Docker. Check your installation with docker --version and docker compose version. Portainer requires Docker to run as root and be accessible through the Unix socket, which is the case with a standard installation.
  • For HTTPS: a domain or subdomain whose A record points to your VPS’s IP address (e.g., portainer.example.com).

Portainer itself uses few resources, and the official documentation doesn’t specify fixed minimum requirements. The containers you manage with it will determine what you need. As a guideline for a server running Portainer and a few smaller applications:

HardwareMinimumRecommended
CPU1 vCPU core2 vCPU cores
RAM1 GB2 GB
Storage10 GB20 GB

Prepare the firewall

Portainer is accessible as soon as it starts, and whoever first opens the page with a valid setup token can create the administrator account. So don’t expose the interface publicly in the first place. With ufw, allow only SSH and the ports for the reverse proxy:

Code
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
Warning

Docker bypasses ufw Ports published by Docker using ports: are accessible from outside even if ufw blocks them. Docker adds its own rules ahead of ufw’s. So, as shown in the Compose file below, bind Portainer only to 127.0.0.1. For more information about the firewall, see Firewall management on Linux.

Install with Docker Compose

Create a directory for Portainer and navigate to it:

Code
mkdir -p /opt/portainer
cd /opt/portainer

Create the Compose file with nano docker-compose.yml. It’s based on the Compose file from the official Portainer documentation:

Code
services:
  portainer:
    container_name: portainer
    image: portainer/portainer-ce:lts
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data
    ports:
      - 127.0.0.1:9443:9443

volumes:
  portainer_data:
    name: portainer_data

Here’s what the entries mean:

  • image: The official Portainer CE image in the lts (Long Term Support) channel. If you want to manage updates yourself, specify a fixed version instead, such as portainer/portainer-ce:2.45.3.
  • /var/run/docker.sock: The Docker socket. Portainer uses it to manage Docker on your server.
  • portainer_data:/data: Users, settings, and stacks are stored in the portainer_data volume.
  • 127.0.0.1:9443:9443: The interface is available over HTTPS with a self-signed certificate, and can only be accessed from the server itself. The 8000 port from the official file is intentionally omitted; it’s only needed for Edge Agents.
Warning

Docker socket access means root access Anyone who can use the Docker socket can start any container on the server, including containers that mount the host’s entire file system. An administrator account in Portainer is therefore practically as powerful as root on your VPS. Use a long, unique password, give accounts only to people you’d also give SSH access to, and don’t leave the interface exposed without HTTPS.

Start the container:

Code
docker compose up -d

Check whether it’s running with docker compose ps.

First access

You have 5 minutes after startup to create the administrator account. First, read the setup token from the logs:

Code
docker logs portainer 2>&1 | grep setup_token

Since Portainer only listens on 127.0.0.1, you’ll access the interface through an SSH tunnel the first time. Run this command on your own computer:

Code
ssh -L 9443:localhost:9443 root@SERVER_IP

Replace SERVER_IP with your VPS’s IP address, then open https://localhost:9443 in your browser. Confirm the warning about the self-signed certificate. Then set your username, password, and setup token as described above under “First login with a setup token,” skip Edge Compute, and click Get Started.

If you miss the 5-minute window, restart the container with docker compose restart portainer and read the token from the logs again.

Access via HTTPS through a reverse proxy

To access Portainer without a tunnel, put a reverse proxy with a valid certificate in front of it. For the basics, see Set up a reverse proxy with nginx and Create an SSL certificate (Let's Encrypt).

The proxy must pass through WebSockets, or the container console and live logs won’t work. Here’s a server block for nginx:

Code
server {
    listen 80;
    server_name portainer.example.com;

    location / {
        proxy_pass https://127.0.0.1:9443;
        proxy_set_header Host $host;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Then obtain the certificate with certbot --nginx -d portainer.example.com. Certbot will add HTTPS and redirect HTTP in the block. Portainer’s self-signed certificate won’t cause any issues; nginx doesn’t verify it between the proxy and the container.

Tip

Shorter with Caddy If you use Caddy instead of nginx, the proxy obtains the certificate itself and passes through WebSockets automatically. Since Portainer uses HTTPS internally with its own certificate, the entry in the Caddyfile needs the tls_insecure_skip_verify option, as shown below.

Code
portainer.example.com {
    reverse_proxy https://127.0.0.1:9443 {
        transport http {
            tls_insecure_skip_verify
        }
    }
}

For more tips on securing your server, see Linux security tips.

Back up your data

Everything that belongs to Portainer itself is stored in the portainer_data volume: users, settings, environments, and your stacks’ Compose files. You have two options:

  • In Portainer: Under Settings, in the Back up Portainer section, click Download backup to download a backup. You can also protect it with a password (Password protect).
  • On the server: Briefly stop Portainer and archive the volume:
Code
cd /opt/portainer
docker compose stop
docker run --rm -v portainer_data:/data -v "$(pwd)":/backup alpine tar -czf /backup/portainer-backup-$(date +%F).tar.gz -C /data .
docker compose start

This doesn’t include data from your other containers. Back up their volumes separately or also use your VPS backups in the web interface.

Update Portainer

Here’s how to get the latest version in the lts channel:

Code
cd /opt/portainer
docker compose pull
docker compose up -d

Back up the portainer_data volume first and read the release notes. If you’ve specified a fixed version, change the version number in docker-compose.yml first. Then remove old images with docker image prune.

Using Portainer

After setup, select the local environment under Home. The sections for that environment then appear on the left, including Containers, Images, Volumes, Networks, and Stacks.

Start an application as a stack

A stack is an application defined by a Compose file, just like one you’d start with docker compose:

  1. Open Stacks and click Add stack.
  2. Name the stack and select Web editor.
  3. Paste in the contents of your Compose file and click Deploy the stack.

Portainer saves the Compose file. Later, you can edit it in the stack and deploy the changes with Update the stack. If your Compose file is in a Git repository, you can also load the stack directly from there.

Logs, console, and resources

Under Containers, click a container to view its details. You’ll find Logs for the container output, Console for a shell inside the container, and Stats for CPU, RAM, and network usage, among other things. This is often the quickest way to narrow down an issue.

Connect additional servers

You can manage additional Docker servers using the Portainer Agent. In Portainer, go to Environments and add a new Docker Standalone environment with an agent. Portainer will show you the appropriate docker run command for the agent, which you’ll run on the other server. The agent listens on port 9001. On the other server, allow access to this port only from the IP address of your Portainer server, for example:

Code
ufw allow from PORTAINER_SERVER_IP to any port 9001 proto tcp

Remember that Docker can also publish ports while bypassing ufw. The agent also has full access to the other server’s Docker socket.

Limitations

  • Edge Agents: The One-Click App only exposes the web interface through your domain, not the tunnel port 8000. So, you can only connect remote devices through Edge Agents with a tunnel when using the manual installation, with port 8000 opened as well.
  • Not a replacement for managing One-Click Apps: Install, update, and uninstall apps from the catalog in the dashboard, not in Portainer.
  • Business features: Some features, such as scheduled backups or backups to S3, are only available in the paid Business Edition. This guide covers the Community Edition.

Conclusion

You’ve installed Portainer on your VPS, created the administrator account using the setup token, and learned why access to the Docker socket is so powerful. You can now conveniently manage containers, stacks, and logs in your browser, and connect additional servers through the Portainer Agent if needed.

Prefer not to manage Docker manually? Use the easy One-Click App method described above under “The easy way: Portainer as a One-Click App.”

Free tools

Related tools for servers and developers

View all

FAQ

Frequently asked questions

The One-Click App is the quickest option: Portainer is available over HTTPS on your domain within minutes, with the VPS setting up the reverse proxy and certificate for you. You can install updates from the dashboard. Manual installation with Docker Compose is a good choice if you don’t use One-Click Apps on your server, want to manage a fixed version yourself, or need to connect Edge Agents through tunnel port 8000.
The setup token is only available in the Portainer container logs. Connect to your VPS over SSH and run docker logs $(docker ps -q --filter name=portainer) 2>&1 | grep setup_token for the One-Click App, or docker logs portainer 2>&1 | grep setup_token for a manual installation. Copy the value after setup_token= into the Setup token field. The token is for one-time use and isn’t needed after setup.
Portainer requires you to create the administrator account within 5 minutes of startup. If the time has expired, restart Portainer: restart the One-Click App from its app card in the dashboard, or run docker compose restart portainer for a manual installation. Then read the setup token from the logs again. Use the most recently issued line and create the account right away.

Feedback

Was this article helpful?

Your feedback helps us prioritize and improve content.

0 of 0 people found this article helpful.

Personal support

Need more help than the guide provides?

Our ZAP-Hosting support team knows your product — briefly describe your issue and we'll help you personally.

Zappy knows this guide and answers you right in the chat.