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

February 28th, 2024
How to Install Portainer on Ubuntu 22.04 | Step-by-Step

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.

Shanika is a technical consultant and writer with over eight years of experience as a software engineer in the IT sector. Her professional journey started as a software engineer with WSO2. At the same time, she started working as a freelancer on Upwork. She has collaborated with numerous companies throughout her freelance career, including Digication, Splunk, BMC.com, Filestack, APILayer, Flosum, Blazemeter, Sencha, and over twenty others. Having opportunities to work with various companies in different roles has allowed her to amass a wealth of experience. Shanika is an expert in web development, programming, Java, Python, React, Cypress, CI/CD, Docker, and Kubernetes,m. She has significantly contributed to developing products such as IAM solutions, APIs, OCR technologies, test management systems, and front-end frameworks throughout her career. She has also produced blog articles, tutorials, user guides, product documentation, and many other documents, as well as consulting companies to enhance their productivity. Overall, Shanika brings together the experience of a web developer, automation engineer, DevOps developer, software consultant, and technical writer, which is the main reason behind her success as a freelancer. Shanika received her B.Sc. (Hons) in Computer Science from University of Moratuwa, Sri Lanka and resides in Colombo, Sri Lanka.

Start Building Now

Deploy your new Cloud VPS server in 3 minutes starting from $5.83 / month.

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: 0cab4b92.684