Cyber Month Deal - up to 36% OFF

How to Install Portainer on Ubuntu 22.04 | Step-by-Step

Published on Feb 28, 2024 Updated on Oct 22, 2024

Portainer is gaining popularity by providing an easy-to-use and powerful web-based interface for managing Docker containers. In this step-by-step tutorial, I will show you how to install Portainer on Ubuntu 22.04 and use it to your advantage.

Portainer vs. Docker

When deploying and managing Docker containers, what usually comes into the minds of most development teams is the Docker CLI (Command Line Interface). And for a good reason. The Docker CLI is a powerful, fast, and versatile tool that allows you to manage any container-related tasks efficiently.

You can start, stop, delete containers, and manage container images, networks, and volumes. The CLI is, as a matter of fact, the most preferred tool in handling containers. As a beginner, you will most likely learn Docker from the command line.

Thankfully, some GUI tools have simplified working with Docker containers. One tool that stands out from the rest is Portainer. First, I’ll briefly explain what Portainer is and then demonstrate how to install Portainer on Ubuntu 22.04.

What is Portainer?

Portainer is an open-source and lightweight web UI tool that simplifies the management of Docker and Kubernetes environments. Its seamless integration with multiple environments and its user-friendly and intuitive UI make it a valuable GUI tool for managing containerized applications and services.

What is Portainer used for?

Portainer is a user-friendly and intuitive container management software built to simplify managing containers. Portainer's intuitive GUI interface removes the complexities of container management. It allows you to deploy and manage containers easily alongside associated resources such as container images, volumes, clusters, etc.

Portainer editions

Portainer comes in two distinct editions: Business and Community Edition. The Community Edition (Portainer CE) is free to download and use, tailored for individuals and home labs. It enjoys community support but has limited features. The Business Edition (Portainer BE) is a commercial edition with a rich feature set, including registry management and RBAC (Role-Based Access Control).

How to use Portainer?

By eliminating running commands on the command line, Portainer users can easily glance at the state of containers, view their logs (business feature), and add/remove networks, volumes, and tech stacks, to mention a few resources.

In addition, you can use Portainer to seamlessly connect to existing environments such as Kubernetes, Docker Swarm, and ACI via a URL or web socket using a simple and intuitive wizard. The Business Edition allows you to provision a Kubernetes cluster on an existing infrastructure and connect to Hashicorp Nomad via an API.

Now, let’s dive right in and see how to install Portainer on Ubuntu 22.04.

Prerequisites

To follow along in this tutorial, ensure you have the following requirements in place:

  • An instance of Ubuntu 22.04 with SSH access;
  • A sudo user configured on the server.

Install Portainer on Ubuntu 22.04: Step-by-step process

To install Portainer on Ubuntu, we need to install Docker first to support the installation of Portainer (because Portainer runs as a Docker container). Once Docker is installed, we can install Portainer by pulling its image and running its container. You can then use Portainer to manage the Docker environment.

Step 1: Update package lists

As the first step, log into your server instance and update the local package index.

sudo apt update

Once the local cache is updated, proceed to the next step.

Step 2: Install Docker

Before we can install Portainer, we need to install Docker. To install Docker from the default Ubuntu repositories, run the APT command as follows.

sudo apt install docker.io -y

The command installs Docker alongside a host of other additional packages and dependencies.

install-docker-ubuntu-22.04

Docker starts automatically upon installation on Ubuntu and other Debian-based distros. To confirm this, check its status as follows.

sudo systemctl status docker

The following output confirms that Docker is up and running as expected.

check-docker-status--ubuntu-22.04

If, for some reason, the service is in an inactive state, start it as shown.

sudo systemctl start docker

Add the currently logged-in user to the docker group to run Docker commands without switching to a sudo user.

sudo usermod -aG docker $USER

For this to come into effect, start a new shell or close and open a new terminal session.

Step 3: Install Portainer on Ubuntu

With Docker already in place, let’s now install Portainer. Pull the latest Portainer image from the Docker hub using the docker pull command.

docker pull portainer/portainer-ce:latest

You should see the following output on your screen.

docker-pull-portaner-image--ubuntu-22.04

To confirm the existence of the image, run the docker images command.

docker images

The output provides details about the newly pulled Portainer image, including the repository, tag, image ID, date of creation, and container size.

confirm-portainer-docker-image

Next, invoke the docker run command to start the Portainer container as shown.

docker run -d -p 9000:9000 --restart always -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer-ce:latest

The command runs a container in the background using the -d flag and binds the TCP port 9000 on the container to TCP port 9000 on the server using the -p option.

Run the docker ps command to verify that the container is active and running.

docker ps

The output contains the container ID, image name, ports, port mapping, the duration that the container has been running, and the container name.

run-portainer-docker-container

Step 4: How to access Portainer web interface

To access Portainer’s web interface, launch your web browser and browse this URL

http://server-ip:9000

NOTE: Sometimes, you can run into the error showing that the container has timed out for security purposes, as shown below.

portainer-container-timeout

As a workaround, restart the container using the docker stop and docker start commands as shown below.

docker stop contaner_ID
docker start contaner_ID

restart-portainer-docker-contaner

When you browse the URL, you will be required to create an administrative user. Therefore, provide a username and a strong password and click Create User.

create-admin-user-portainer-docker

Step 5: Get started: Deploy a Docker container

Once you've created an admin user, you will be guided to the Quick Setup page. Since only one Portainer environment is currently sitting on your local environment, select the Get Started option.

portainer-quick-setup-get-started

Next, click the Live connect button.

portainer-live-connect

You will be directed to your environment’s dashboard. On the left navigation bar, click Containers to start creating a container.

portainer-start-creating-docker-container

Next, click the add container button to the far left to create containers. You can already see that the Portainer image is listed as running on the container list.

portainer-container-list-add-container

On the Create Container page, specify the container details such as the container name, registry (by default, this is set to Docker Hub), and image. If you are unsure about the image name, click the Search button, which will take you to Docker Hub, where you can verify the correct image name.

create-container-portainer

Finally, click the Deploy the Container button.

portainer-deploy-container-after-specifying-details

A few moments later, the running container will appear on the container list, as shown below. In this example, we have deployed a Redis container.

docker-containers-portainer

You can confirm the running container on the command line by running docker ps once more. The output below shows an additional container running with the tag redis:latest. This confirms that our Redis container is running as expected.

verify-running-containers-docker-portainer

From the Portainer dashboard, you can perform a host of other operations, such as starting, stopping, restarting, and pausing containers.

Takeaway

This tutorial demonstrated how to install Portainer on Ubuntu 22.04. Portainer simplifies container management via easy-to-use web UI to manage containers and complex clusters such as Kubernetes and Docker Swarm. For more information on Portainer, check out the official Portainer documentation.

Cloud VPS - Cheaper Each Month

Start with $9.99 and pay $0.5 less until your price reaches $6 / month.

Share this article

Related Articles

Published on Apr 10, 2024 Updated on May 15, 2024

How to Install Nextcloud AIO on Docker | Step-by-Step

This tutorial will show you how to install Nextcloud using Nextcloud AIO Docker image to help significantly reduce configuration steps.

Read More
Published on May 15, 2024 Updated on May 15, 2024

Portainer Tutorial: How to Update [and Restart] Portainer

This tutorial demonstrates how to manage Portainer: how to update Portainer, how to restart Portainer, and update existing containers.

Read More
Published on Apr 14, 2020 Updated on Feb 6, 2024

Docker Swarm vs. Kubernetes – What are the Subtle Differences?

Kubernetes and Docker Swarms are essential tools used to deploy containers inside a cluster. Learn how they differ and when to use them

Read More
We use cookies to ensure seamless user experience for our website. Required cookies - technical, functional and analytical - are set automatically. Please accept the use of targeted cookies to ensure the best marketing experience for your user journey. You may revoke your consent at any time through our Cookie Policy.
build: 06ac5732e.831