How to Install and Use Portainer to Manage Docker Containers

This step-by-step guide shows how to install Portainer to take control of your Docker containers via a convenient GUI.

In the world of containerization, Docker has emerged as a dominant force, revolutionizing how software applications are deployed and managed.

However, as Docker environments grow in complexity and scale, managing containers and orchestrating their operations can become increasingly challenging.

This is where Portainer steps in as a powerful and user-friendly graphical user interface (GUI) tool explicitly designed to simplify Docker container management.

What’s Portainer?

Portainer is a tool designed to simplify the management and monitoring of Docker containers. It provides a user-friendly graphical interface, allowing users to interact with Docker easily and perform container-related tasks without complex command-line operations.

Portainer allows users to manage Docker containers, images, networks, and volumes through an intuitive web-based interface. It offers a centralized platform for container management, making it an ideal choice for experienced Docker users and those new to containerization.

Furthermore, Portainer supports managing multiple Docker hosts, making it an excellent choice for organizations or individuals working with complex Docker deployments across different environments.

At the same time, Portainer can work alongsideย Docker Compose, allowing users to easily deploy and manage the entire application stack defined in Docker Compose, view the status and logs of individual containers, and scale services as needed.

Finally, the application is not limited to Docker only. Portainer also supports Kubernetes and Docker Swarm, allowing admins to manage and secure the cluster quickly.

What’s the Portainer Agent?

Portainer offers a Remote Agent โ€“ a lightweight, standalone component that works with Portainer to provide advanced container management capabilities.

It runs as a container on the remote host and acts as a bridge between Portainer and the Docker environment, allowing the management of remote Docker resources.

Furthermore, Portainer Agent allows a single Portainer instance to connect to multiple Docker hosts, eliminating the need for direct access to the Dockerized remote host or complex networking configurations.

In other words, by offering centralized management of multiple remote Docker instances, Portainer Agent makes remote Docker management seamless and efficient.

Portainer Editions

Portainer offers two different editions, each catering to different user requirements and environments.

Portainer Community Edition (CE)

Portainer CE is a free and open-source offering for individual users, small teams, and non-commercial use. It provides a user-friendly web interface for managing Docker containers, images, networks, and volumes, suitable for most Docker management needs. It offers a comprehensive set of tools and functionalities without any licensing fees.

Portainer Business Edition (BE)

Portainer BE is the commercial edition of Portainer, tailored for organizations and enterprise users. It builds upon the features of Portainer CE but includes additional advanced capabilities, support, and services designed to meet the needs of larger teams, complex deployments, and production environments.

For example, Portainer BE offers additional features like role-based access control (RBAC), LDAP/AD integration, enhanced security features, fine-grained access controls, container lifecycle management, and more.

The table below shows the differences between the two editions.

FeaturePortainer CEPortainer BE
Target AudienceSmall teams, hobbyists, individual usersEnterprise teams and large organizations
User and Role ManagementBasic RBAC, limited controlAdvanced RBAC with granular control
Security FeaturesBasic authentication, TLSSSO, advanced security policies, audit logging
ScalabilitySuitable for small environmentsOptimized for large-scale environments
SupportCommunity forums, no SLAProfessional support with SLAs
Audit LoggingNo audit loggingFull audit logging for compliance
Kubernetes ManagementBasic Kubernetes supportAdvanced features like multi-cluster support
AutomationBasic container managementAdvanced automation and orchestration
Registry ManagementBasic registry supportAdvanced registry control and multiple registries
Extensions & PluginsCore functionality onlyAdditional enterprise plugins and integrations
PricingFree and open-sourcePaid subscription based on node count

Prerequisites

Having Docker installed is a must for installing Portainer. So, if you don’t already have Docker installed, you must install it before installing Portainer.

Here are a few guides to help you do it quickly in just minutes.

The other essential component is Docker Compose. Remember, it is provided separately from Docker. Therefore, you must Install Docker before adding Docker Compose; otherwise, Compose will not function.

Installing it is pretty simple, even if it is not already on your Linux system. To install Docker Compose, type the following two commands:

sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-composeCode language: Bash (bash)

Docker Compose is not required to use Portainer. Still, it is highly recommended because it allows you to take advantage of the full potential of Docker by deploying your Dockerized multi-container applications/stacks via Pontainer’s user-friendly web-based interface.

Finally, if your Linux system uses SELinux, it should be disabled before installing Portainer. However, if you require SELinux, you must pass the --privileged flag to Docker when deploying Portainer.

How to Install Portainer

Before we begin, it is important to note that Portainer can be installed on various platforms, including Linux, Windows, and macOS. This guide will focus on installing Portainer CE (Community Edition ) on Linux.

Step 1: Create Docker Volume

First, we’ll create a Docker volume called “portainer_data” to persist the Portainer’s configuration files.

docker volume create portainer_dataCode language: Bash (bash)
Create a Docker volume.
Create a Docker volume.

If the operation is successful, the command’s result will output the volume’s name.

Step 2: Install Portainer CE on Linux

After you’ve created the volume, use the following command to deploy the Portainer container itself.

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:latestCode language: Bash (bash)
Install Portainer on Linux.
Install Portainer on Linux.

Now, let’s break down the syntax and explain the meaning of each value.

  • -d:  Tells Docker to run the container in detached mode (in the background).
  • –name: Specifies the name of the container.
  • -p: Expose the default Portainer’s ports 8000 and 9443 to the hostโ€™s ports 8000 and 9443.
  • –restart: Instructs Docker to restart the container if it exits for any reason.
  • -v: Because Portainer needs to communicate with the Docker daemon to manage containers, you must mount the host’s Docker socket into the container. In addition, we’re mounting the Docker volume we created earlier to the container, where Portainer’s configuration files will be stored.
  • The last option specifies the Docker image from which our container will be created. We use the most recent version of the Portainer CE edition, which is available onย Docker Hub.

The command will pull the Portainer Docker image and start the container. We can check if Portainer is running by typing the command below, which lists our system’s currently running Docker containers.

docker psCode language: Bash (bash)
List the currently running Docker containers.
List the currently running Docker containers.

As you can see from the output above, our Portainer server is running.

Access the Portainer Web UI

To access the Portainer dashboard, load “https://localhost:9443” in your browser. Because Portainer issues a self-signed SSL certificate, you are shown a potential security risk message. Accept it to proceed.

Accept the security warning.
Accept the security warning.

You’ll be taken to a page where you can create the administrative account for your Portainer instance. Enter a username (the default suggestion is “admin“) and a password of at least 12 characters, then click the “Create user” button.

Create Portainer's admin account.
Create Portainer’s admin account.

The “Quick Setup” page will appear. From here, you can add Docker environments to your Portainer server.

However, since we mounted the host’s Docker socket to the Portainer container when we started the container, it is already connected. So, click the “Home” button.

Connect to the local Docker instance.
Connect to the local Docker instance.

Portainer will show you it is connected to your local Docker environment, named “local.” Click on it.

Portainer successfully connected to the local Docker environment.
Portainer successfully connected to the local Docker environment.

Congratulations! From here, using the menu on the left, you can now create and manage your Docker containers, networks, images, and volumes by using the convenient web-based Portainer UI.

Manage Docker containers with Portainer.
Manage Docker containers with Portainer.

Connect Portainer to Remote Docker Environment

First, you must install the Portainer Agent to connect a Portainer to a remote Docker environment and manage containers.

So, connect to the remote server (which must be running Docker) via SSH, for example, and execute the command below to install the Portainer Agent.

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.18.3Code language: Bash (bash)
Install Portainer Agent on a remote Docker environment.
Install Portainer Agent on a remote Docker environment.

Next, switch back to Portainer, and from the left menu, choose “Environments,” then click on the “Add environment” button.

Connect Portainer to remote Docker environment
Connect Portainer to remote Docker environment

Choose “Docker Standalone” and hit “Start Wizard.”

Connect Portainer to remote Docker environment.
Connect Portainer to remote Docker environment.

In the “Name” field, specify a name for the remote Docker environment. Next, enter the server’s IP address followed by “:9001” in the “Environment address” field. Finally, click the “Connect” button.

You should receive a message that the connection was successful. To return to the Portainer’s dashboard, click on the logo in the upper left corner.

Connect Portainer to remote Docker environment.
Connect Portainer to remote Docker environment.

The newly added remote Docker environment is now on the list of available ones. Click on it.

Portainer has been successfully connected to a remote Docker environment.
Portainer has been successfully connected to a remote Docker environment.

You can now manage your remote Docker environment through Portainer, just like your local one.

Manage remote Docker environment.
Manage remote Docker environment.

Conclusion

The installation and usage of Portainer to manage Docker containers provide a powerful and user-friendly solution for efficiently managing containerized applications, making it an ideal tool for individuals and organizations of all sizes.

With its intuitive interface and comprehensive feature set, Portainer simplifies managing and monitoring Docker containers, making it accessible even to those with limited technical expertise.

For additional help or useful information, we recommend you check the official Portainer documentation or visit the project’s website.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%