How to Install Docker Portainer on Linux

May 19, 2022

Introduction

Portainer is a lightweight container management tool that provides a GUI for simplifying container operations. It supports all the major orchestration platforms - Kubernetes, Nomad, ACI, and multiple Docker environments (Docker hosts and Swarm clusters).

This tutorial will show you how to install Portainer for Docker on Linux. It will also provide instructions for using Portainer to deploy a containerized app.

How to install Docker Portainer on Linux

Prerequisites

  • The latest version of Docker installed and running as root.
  • Administrative access to the system.

Note: The tutorial covers the installation steps for Portainer Community Edition. Portainer also has a business edition, which requires purchasing a license.

Docker Portainer Installation

Portainer is deployed as a lightweight Docker container on any Linux system running Docker. The main component of Portainer is Portainer Server, which is used to manage containers, networks, and environments. Portainer Agent is the component installed on another Docker system to enable communication with the server.

Follow the steps below to install Portainer and deploy a containerized app to test the installation.

Step 1: Create Docker Volume

Portainer stores information on a Docker volume. Type the following command to create a Docker volume for the Portainer Server:

docker volume create portainer_data

If the operation is successful, the system outputs the name of the volume.

Creating a Docker volume for Portainer data.

Step 2: Install Portainer Server

The latest Portainer Community Edition image is available on Docker Hub. Use the docker run command to pull the image and start a Portainer Server container:

docker run -d -p 8000:8000 -p 9443:9443 --name portainer \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:2.9.3

Portainer exposes the UI via the secure port 9443. Port 8000 is used for edge computing and is optional unless you are planning to use edge agents.

Using the docker run command to pull the Portainer CE image from the Docker Hub and start a container.

Note: BMC offers affordable instances that satisfy all the performance requirements for edge computing.

docker run pulls the necessary images and starts the container. Check that Portainer is running by typing:

docker ps

The command lists all the running containers. Find the container named portainer and make sure its status is Up.

Checking the status of running containers.

Step 3: Access Portainer Dashboard

Portainer has a web UI accessible through an internet browser. To access the main Portainer dashboard:

1. In a browser, visit the following address:

https://localhost:9443

Note: If you receive a blank page with the Client sent an HTTP request to an HTTPS server message, make to explicitly state HTTPS as the connection type.

2. The first time you access Portainer, the system asks to create a password for the admin user. Type the password twice and select the Create user button.

Creating a password for the admin account in Portainer.

The Environment Wizard starts.

3. Select the Get Started button to go to the dashboard and start using Portainer in the local environment only. To add other environments during the initial setup, click Add Environments.

Starting the Environment Wizard in Portainer.

Note: You can add environments later from the Portainer dashboard.

Step 4 (Optional): Add More Environments to Portainer Installation

You can manage multiple Docker environments within the Portainer UI. Moreover, each environment needs to have a Portainer Agent instance installed. The agent then uses port 9001 to communicate with the server.

Follow the steps below to add an environment to Portainer.

1. Type the following command to start a Portainer Agent container on the system you want to add:

docker run -d -p 9001:9001 --name portainer_agent --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes portainer/agent:2.9.3

Wait for Docker to pull the necessary images and initiate the container.

Installing a Portainer Agent instance with the docker run command.

2. To register the new environment in Portainer, you need the IP address of the system hosting the environment. If you do not know the IP, use the ip command to obtain it:

ip a

The command lists the network interfaces on your system. Make a note of the main interface's IP address.

Using the ip command to find the IP address of the main network interface.

Return to the Portainer Server UI.

3. Select Environments in the menu on the left side and click Add environment.

Navigating to the Add environment page in Portainer.

Note: If you select the Add Environments button in Step 3, Portainer takes you directly to the Create Environment page.

On the Create Environment page, fill in the details about the environment you want to add.

4. Write the name of the environment in the Name field

5. Type the URL of the system running Portainer Agent in the Environment URL field.

[ip-address]:9001

6. When you finish the setup, select the Add environment button in the Actions section.

Setting up a new environment to connect with Portainer Server.

The new environment appears on the Environments page.

The Environments list showing the newly created environment.

Step 5: Deploy Container Using Portainer

Test your Portainer setup by deploying a test Docker container. Follow the steps below to install an Apache HTTP Server instance.

1. Select Containers in the menu on the left side to open the Containers page.

Navigating to the Containers section in Portainer.

2. Click the Add container button in the action bar.

The location of the Add container button in the Containers section.

3. Provide details for the container you want to run, including the container name, the image name, and the connection ports.

Setting up a new container deployment in Portainer.

4. When you finish setting up the container, scroll to the bottom of the page and select the Deploy the container button.

Location of the Deploy the container button in Portainer.

Wait for Portainer to deploy the container. When the container is ready, its state will be running.

The list of containers with the newly created container.

5. Open another browser tab and type the IP address of your environment followed by the port assigned to the container. The Apache server shows the confirmation message.

The httpd page confirming the successful installation.

Conclusion

After going through the steps in this tutorial, you will learn how to install Portainer to manage Docker containers on Linux.

The tutorial covered the steps for installing the Portainer Server instance and the procedure for adding environments to your installation.

Was this article helpful?
YesNo
Marko Aleksic
Marko Aleksić is a Technical Writer at phoenixNAP. His innate curiosity regarding all things IT, combined with over a decade long background in writing, teaching and working in IT-related fields, led him to technical writing, where he has an opportunity to employ his skills and make technology less daunting to everyone.
Next you should read
Should You Run Privileged Docker Containers?
September 10, 2020

In this tutorial, you will learn what privileged Docker containers are, when to use them, and whether it is a good option for you.
Read more
Podman vs Docker: Everything You Need to Know
December 12, 2023

This article will compare two container management engines - Docker and Podman. It will also help you choose...
Read more
How to Set Docker Memory and CPU Usage Limit
December 6, 2023

By default, Docker containers have access to the full RAM and CPU resources of the host. Leaving them to run with these default...
Read more
Kubernetes vs Docker Swarm: What are the Differences?
May 19, 2022

The orchestration tools we will stack up against each other are Kubernetes vs. Docker Swarm. There are several differences...
Read more