Install Portainer on Debian

How to Install Portainer on Debian 11

In this article, you’ll learn how to install Portainer on Debian 11 to manage and run Docker containers using a GUI. Continue reading this article to find out more!

Docker is a widely used container engine that allows developers to build and run their containers. However, docker supports a command-line interface. 

This makes it difficult for beginners to manage the containers via CLI. However, by using Portainer, a web-based GUI for managing Docker and Kubernetes containerization, they can manage and deploy containerized applications efficiently. 

Prerequisites

For this article, you’ll need a Debian machine with root privilege or sudo user access. In addition, you should have dependencies, Docker and Docker Compose installed on the Debian machine. 

How to Install Portainer on Debian 11

In this section, we’ll cover how to use and install Portainer on Debian 11. Portainer is available in both the community edition and the business edition. You’ll learn about the community edition in this guide. Also, there are different environments where you can deploy Portainer, such as:

  • Standalone Docker container
  • Docker Swarm
  • Kubernetes

In this guide, you’ll deploy Portainer on Debian 11 as a Docker container.

Make sure that you have all the dependencies installed. Otherwise, the Portainer will not work properly.

Update the System

Before starting with the installation, you’ll update the machine first. For this step, use the APT package manager with the update command. First, open the terminal by pressing “Ctrl + Alt + T”. Next, specifically, type:

sudo apt update && sudo apt upgrade -y

The output should look something like this:

Update Debian Machine

Verify the Docker and Docker Compose

To ensure that the Docker and Docker Compose exist in the machine, you’ll verify it by typing the application name followed by the –version or -v tag. For example:

docker –version
docker -v
docker-compose –version
docker-compose -v

Install Portainer on Debian

Once the installation is verified, you’ll now install Portainer on Debian. First, create a volume to store Portainer. The syntax of the command looks like this:

docker volume create [OPTIONS] [VOLUME-NAME]

This command creates a volume under the Docker path. Make sure to replace VOLUME_NAME with the name of your preference. For instance, to create a volume named portainer_data, execute this command:

docker volume create portainer_data

Next, verify that the volume is created by executing the command given below:

docker volume ls

To inspect volume details, type:

docker volume inspect pt_data

After that, run the docker command with the required parameters to download and run the Portainer image from Docker. To be specific, type:

docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ee:latest /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ee:latest

The output should look something like this:

Install Portainer on Debian

Let’s look at this command in detail:

  • -d/–detach: runs the container in the background and prints the output
  • -p/–publish: publishes a container’s port to the Docker Container
  • –name: sets a name to the container
  • –restart: restarts the policy when the new container is created
  • =always: always restart the container regardless of the exit status. Also, start the container on daemon startup. 
  • -v/–volume: mount a Docker container volume
  • -v /var/run/docker.sock:/var/run/docker.sock: Through this argument, the Portainer server communicates with the main Docker process. 
  • -v pt_data:/data: Mounts the Portainer Server container to the host path.
  • Portainer-ee:latest: uses the latest Portainer community edition container image, portainer/portainer-ce:latest.

For a detailed analysis, run the docker command with –help argument. For example, type:

docker run --help
docker run -h

By default, Portainer uses a self-signed SSL certificate to reserve port 9443. However, you can use your SSL certificate once the installation is complete by running this command:

-p 9000:9000

That’s it! You are done with the Portainer installation. 

Access Portainer Interface on Debian 

Now that the Portainer is installed, you can access it. Navigate to the web browser and type the following URL:

http://your-server-ip:9443
# for legacy HTTPS Port
http://your-server-ip:9000

Make sure to replace the your-server-ip with the server address. If you’re not running a server, then replace it with localhost. Specifically, type:

http://localhost:9443
# for legacy HTTPS Port
http://localhost:9000

Alternatively, you can also login using your IP address. To find the IP of your machine, type the ifconfig or hostname command. For example:

ifconfig -a
hostname -I | awk '{print $1}'

You will get the login page which should look like this:

Login to Portainer Dashboard

Create a new admin user and enter your username and password. Once you’ve logged in successfully, you’ll get the Portainer dashboard.

Click the Get Started button to start managing Docker Container:

Use Portainer on Debian

Bonus: Install Docker and Docker Compose

To install Docker and Docker Compose, first, install the required dependencies by executing the command given below:

sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common lsb-release -y

The output should look something like this:

Install Portainer on Debian

After that, add the Docker GPG key and repository:

sudo curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
sudo curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
sudo echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null

Next, update the APT repository and install Docker Community Edition:

sudo apt update -y
sudo apt upgrade -y
sudo apt install docker-ce -y

Wait for the installation to complete. Lastly, verify the Docker version by using the docker command as shown below:

docker --version
docker -v

Along with Docker, you’ll also need Docker Compose. For its installation, add the Docker Compose binary to your system using the wget command. To be specific, type:

wget https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-x86_64

After that, copy the downloaded binary using the cp command:

cp docker-compose-linux-x86_64 /usr/local/bin/docker-compose

Next, assign the executable permissions to the Docker Compose binary file:

chmod +x /usr/local/bin/docker-compose

After that, install the Docker Compose as shown below:

sudo apt install update -y
sudo apt install upgrade -y
sudo apt install docker-compose -y

lastly, verify the Docker Compose installation using the docker-compose command:

docker-compose --version
docker-compose -v

And there you go. You have learned how to install Portainer on Debian 11. You can now create, run and deploy containers using a web-based interface via Portainer. For more information, check out the Portainer guide

If you found this article to be useful, please share it.

Related Posts