Cyberithub

How to Install Portainer on Ubuntu 22.04

Advertisements

In this article, we will see how to install Portainer on Ubuntu 22.04. Portainer is an open source, lightweight container management platform which can be used to manage Docker, Swarm, Kubernetes and ACI environments. It consists of a single container which can be easily deployed as either a Linux container or a Windows native container in any cluster. The application allows you to manage almost all your orchestrator resources such as containers, images, volumes etc through a smart GUI Interface. It can be easily installed on almost all the famous platforms. Here we will see the steps to install Portainer on Ubuntu 22.04 based servers.

 

How to Install Portainer on Ubuntu 22.04

How to Install Portainer on Ubuntu 22.04

Also Read: How to Install Aerospike on Ubuntu using 8 Easy Steps

Step 1: Prerequisites

a) You should have a running Ubuntu 22.04 Server.

b) You should have sudo or root access to run privileged commands.

c) You should have apt or apt-get package manager available in your Server.

 

Step 2: Update Your Server

It is always recommended to first check for all the latest available updates and install them by using sudo apt update && sudo apt upgrade command before installing any new packages in your Server. This will keep your system updated with latest security patches and bug fixes.

cyberithub@ubuntu:~$ sudo apt update && sudo apt upgrade
Hit:1 https://artifacts.elastic.co/packages/8.x/apt stable InRelease
Hit:2 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu jammy InRelease
Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:5 http://in.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:6 http://in.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:7 https://ngrok-agent.s3.amazonaws.com buster InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
9 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.

 

Step 3: Install Docker

Since portainer requires a container based platform to be deployed as container so before installing portainer you need to install docker in your Server. This can be done by running sudo apt install docker.io command as shown below. This will download and install docker package along with all its dependencies from default Ubuntu repo.

cyberithub@ubuntu:~$ sudo apt install docker.io
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
ca-certificates
Suggested packages:
aufs-tools btrfs-progs cgroupfs-mount | cgroup-lite debootstrap docker-doc rinse zfs-fuse | zfsutils
The following NEW packages will be installed:
ca-certificates docker.io
0 upgraded, 2 newly installed, 0 to remove and 9 not upgraded.
Need to get 29.1 MB of archives.
After this operation, 113 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 ca-certificates all 20230311ubuntu0.22.04.1 [155 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 docker.io amd64 24.0.5-0ubuntu1~22.04.1 [28.9 MB]
Fetched 29.1 MB in 9s (3,378 kB/s)
Preconfiguring packages ...
Selecting previously unselected package ca-certificates.
(Reading database ... 233945 files and directories currently installed.)
Preparing to unpack .../ca-certificates_20230311ubuntu0.22.04.1_all.deb ...
..................................................

 

Step 4: Verify Service Status

Now that docker is installed, it is important to verify the service running status by using sudo systemctl status docker command as shown below. If you see service in inactive state then you can start it by using sudo systemctl start docker command. You can also restart the service by running sudo systemctl restart docker command.

cyberithub@ubuntu:~$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-09-13 18:48:25 IST; 7s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 205036 (dockerd)
      Tasks: 10
     Memory: 48.8M
        CPU: 2.594s
     CGroup: /system.slice/docker.service
             └─205036 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Sep 13 18:48:18 ubuntu dockerd[205036]: time="2023-09-13T18:48:18.229789607+05:30" level=info msg="Starting up"
Sep 13 18:48:18 ubuntu dockerd[205036]: time="2023-09-13T18:48:18.313155014+05:30" level=info msg="detected 127.0.0.53 nameserver, assuming systemd-resolved>
Sep 13 18:48:21 ubuntu dockerd[205036]: time="2023-09-13T18:48:21.219886788+05:30" level=info msg="[graphdriver] using prior storage driver: overlay2"
Sep 13 18:48:21 ubuntu dockerd[205036]: time="2023-09-13T18:48:21.597707968+05:30" level=info msg="Loading containers: start."
Sep 13 18:48:23 ubuntu dockerd[205036]: time="2023-09-13T18:48:23.555237419+05:30" level=info msg="Default bridge (docker0) is assigned with an IP address 1>
Sep 13 18:48:23 ubuntu dockerd[205036]: time="2023-09-13T18:48:23.958455182+05:30" level=info msg="Loading containers: done."
Sep 13 18:48:25 ubuntu dockerd[205036]: time="2023-09-13T18:48:25.133655846+05:30" level=info msg="Docker daemon" commit="24.0.5-0ubuntu1~22.04.1" graphdriv>
Sep 13 18:48:25 ubuntu dockerd[205036]: time="2023-09-13T18:48:25.165473924+05:30" level=info msg="Daemon has completed initialization"
Sep 13 18:48:25 ubuntu systemd[1]: Started Docker Application Container Engine.
Sep 13 18:48:25 ubuntu dockerd[205036]: time="2023-09-13T18:48:25.796990716+05:30" level=info msg="API listen on /run/docker.sock"

 

Step 5: Install Portainer

In the next step, you can pull the latest portainer image from docker registry by using sudo docker pull portainer/portainer-ce:latest command as show below.

cyberithub@ubuntu:~$ sudo docker pull portainer/portainer-ce:latest
latest: Pulling from portainer/portainer-ce
7bd7f95ed7eb: Pull complete
9d019f0c1f3a: Pull complete
5171176db7f2: Pull complete
52e9438966a5: Pull complete
43d4775415ac: Pull complete
c1cad9f5200f: Pull complete
4de43b91ce75: Pull complete
d7c8d69c556b: Pull complete
173ea6e5087e: Pull complete
90767cd90d02: Pull complete
4f4fb700ef54: Pull complete
Digest: sha256:54ec8c7776cf9759f3e4c665a9596c4e0069d6359f4cc012377c6e5f104d8a94
Status: Downloaded newer image for portainer/portainer-ce:latest
docker.io/portainer/portainer-ce:latest

After downloading the image, you can list it by running sudo docker images command as shown below.

cyberithub@ubuntu:~$ sudo docker images
REPOSITORY              TAG     IMAGE ID      CREATED       SIZE
portainer/portainer-ce  latest  434ab9ff1bf0  12 days ago   294MB
nginx                   alpine  8e75cbc5b25c  5 months ago  41MB
ubuntu                  latest  08d22c0ceb15  6 months ago  77.8MB

Now you need to run a container by using the portainer docker image and binding it to Port 9000 using below docker run command.

cyberithub@ubuntu:~$ sudo docker run -d -p 9000:9000 --restart always -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer-ce:latest
362d3fc3cdbfa4ee718f005485ff6de3a10687e1d443cc59a08f4d45880acbde

 

Step 6: Access Web Interface

Now open your favorite web browser from Desktop and enter URL http://<your_server_ip_address>:9000 as shown below. It will first ask you to create administrator user account. You can set the password and click on Create user.

How to Install Portainer on Ubuntu 22.04 2

You will be logged in as admin user as shown below. To proceed using local portainer environment, click on Get Started.

How to Install Portainer on Ubuntu 22.04 3

You will see below local environment currently running. Click on Live connect to manage this environment.
How to Install Portainer on Ubuntu 22.04 4

You will see the local environment getting connected like below.

How to Install Portainer on Ubuntu 22.04 5

 

Step 7: Deploy a Container

Let's now see how to deploy a container in Portainer. For that, you have to navigate to Containers and click on Add container.

How to Install Portainer on Ubuntu 22.04 6

Then provide the container name and image name as shown below. You can also choose the Registry and select/unselect the Always pull the image policy as per your requirement. For the moment, we are using default setting.

How to Install Portainer on Ubuntu 22.04 7

Then scroll down a bit and click on publish a new network port and provide the host and container port number as shown below. Once all the details are provided, click on Deploy the container.

How to Install Portainer on Ubuntu 22.04 8

If everything goes well then it should get deployed and show in running state as highlighted below.

How to Install Portainer on Ubuntu 22.04 9

 

Additional Information

Sometimes you will notice that Portainer instance gets timed out to security reasons and you might see below output while trying to access Portainer Dashboard. In my case, I have faced this issue immediately after installation. So to solve this problem, you need to  restart portainer container.

How to Install Portainer on Ubuntu 22.04 10

You need to first get the right container id from sudo docker ps -a command output as shown below.

cyberithub@ubuntu:~$ sudo docker ps -a
CONTAINER ID  IMAGE                          COMMAND                CREATED      STATUS                  PORTS                                                         NAMES
362d3fc3cdbf  portainer/portainer-ce:latest  "/portainer"           2 days ago   Up 2 hours              8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp naughty_sutherland
8f9ef99d01cc  nginx:alpine                   "/docker-entrypoint.…" 5 months ago Exited (0) 5 months ago                                                               nginx_base
0ce10268bdfd  ubuntu:latest                  "/bin/bash"            5 months ago Exited (0) 5 months ago                                                               ubuntu-system
316006553b49  ubuntu                         "/bin/bash"            5 months ago Exited (0) 5 months ago                                                               hardcore_allen

Then restart the container by using sudo docker restart 362d3fc3cdbf command as shown below.

cyberithub@ubuntu:~$ sudo docker restart 362d3fc3cdbf
362d3fc3cdbf

Now if you refresh the dashboard, you will notice that the error is now gone and dashboard will open as expected.

How to Install Portainer on Ubuntu 22.04 2

Leave a Comment