Portainer is a lightweight management UI that allows you to easily manage your Docker environments. This guide shows how to install Portainer on a Debian server step by step.
Step 1: Update Your System
Before installing anything, make sure your system packages are up to date:
sudo apt update
sudo apt upgrade -y
Step 2: Install Docker and Docker Compose
Install Required Dependencies
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
Add Docker’s Official GPG Key
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
Add the Docker Repository
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/debian
Suites: $(. /etc/os-release && echo "$VERSION_CODENAME")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
Install Docker Engine and Plugins
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 3: Install Portainer
Create the Portainer Directory
cd /opt
sudo mkdir portainer
cd portainer
Create the Docker Compose File
sudo nano portainer-compose.yaml
Paste the following content:
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:
- 9443:9443
- 8000:8000 # Remove if you do not intend to use Edge Agents
volumes:
portainer_data:
name: portainer_data
networks:
default:
name: portainer_network
Save and exit the editor.
Start Portainer
sudo docker compose -f portainer-compose.yaml up -d
Step 4: Allow Portainer Through the Firewall
If you are using UFW, allow port 9443:
sudo ufw allow 9443
Step 5: Access the Portainer Web Interface
Open your browser and go to:
https://YOUR_SERVER_IP:9443
You will be prompted to create an admin account on first launch.
