how to install portainer on ubuntu 22.04

How to install Portainer on Ubuntu 22.04 As Standalone Docker Container

In this short article we will learn how to install Portainer Community Edition on Ubuntu 22.04 LTS operating system as standalone Docker container.

Introduction

Portainer is an open-source management tool designed to simplify the deployment, management, and monitoring of Docker containers and containerized applications. With its user-friendly interface and powerful features, Portainer is an excellent choice for both beginners and experienced developers looking to streamline their container management workflows. In this article, we’ll explore the key features of Portainer, its benefits, and how to get started using it.

Key Features of Portainer

  • User-Friendly Interface: Portainer offers an intuitive web-based interface that makes managing Docker containers accessible to developers of all skill levels.
  • Container Management: You can easily create, start, stop, and remove Docker containers using Portainer’s graphical interface, eliminating the need for complex command-line interactions.
  • Image Management: Portainer enables you to search for, pull, and manage Docker images from various registries directly within the interface.
  • Volume and Network Management: Create and manage volumes and networks for your containers seamlessly, providing isolation and persistence for your applications.
  • Resource Monitoring: Portainer offers real-time monitoring of container resources, including CPU, memory, and network usage.
  • Stacks and Compose Files: Define and manage multi-container applications using Docker Compose files or Portainer’s built-in stack editor.
  • User and Team Management: Portainer allows you to create and manage users and teams, granting specific access levels and permissions to different resources.

Benefits of Using Portainer

  • Ease of Use: Portainer’s user-friendly interface eliminates the learning curve associated with Docker command-line tools, making it accessible to developers with varying levels of experience.
  • Time-Saving: With Portainer’s streamlined management capabilities, you can perform Docker-related tasks more quickly and efficiently.
  • Visual Insights: Portainer’s graphical representation of containers, images, and resources provides a clear overview of your container ecosystem.
  • Collaboration: Teams can collaborate on container management tasks while maintaining control over access and permissions.
  • Consistency: Portainer helps ensure that containers are deployed and managed consistently across different environments.

How To Install Portainer On Ubuntu 22.04

The Portainer hase two edition, namely : Business Edition (BE) and Community Edition (CE).   In this tutorial we will use Portainer CE (Community Version) to be installed on Ubuntu 22.04 system. There are about three different environments in which we can deploy Portainer, namely : Standalone Docker container, Docker Swarm and Kubernetes.

In this tutorial we will use Standalone Docker container as an evironment. To start the Portainer installation we will have sub section as shown below :

  • Prerequisite
  • Step 1: Creating Volume
  • Step 2: Download and install the Portainer Server container
  • Step 3: Verify Portainer has been running

Prerequisite

  1. sudo access on the system
  2. Port 9443 for exposing UI and port 8000 for tunneling server
  3. The latest Docker installed on the system

We have the latest Docker on the system, the discussion about Docker installation on Ubuntu system can be found at How to install Docker on Ubuntu 22.04 LTS operating system article. To verify it we will query the Docker service which is running on the system and Docker version. For this purpose we will submit the following command lines:

$ sudo systemctl status docker
$ docker --version

Output :

ramansah@infodiginet:~$ sudo systemctl status docker
[sudo] password for ramansah: 
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2023-08-26 11:22:46 WIB; 4min 4s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 1220 (dockerd)
Tasks: 10
Memory: 29.4M
CPU: 1.935s
CGroup: /system.slice/docker.service
└─1220 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Agu 26 11:22:38 infodiginet dockerd[1220]: time="2023-08-26T11:22:38.821250481+07:00" level=info msg=">
Agu 26 11:22:38 infodiginet dockerd[1220]: time="2023-08-26T11:22:38.833702458+07:00" level=info msg=">
Agu 26 11:22:39 infodiginet dockerd[1220]: time="2023-08-26T11:22:39.659029534+07:00" level=info msg=">
Agu 26 11:22:39 infodiginet dockerd[1220]: time="2023-08-26T11:22:39.782316658+07:00" level=info msg=">
Agu 26 11:22:44 infodiginet dockerd[1220]: time="2023-08-26T11:22:44.518454480+07:00" level=info msg=">
Agu 26 11:22:45 infodiginet dockerd[1220]: time="2023-08-26T11:22:45.425332642+07:00" level=info msg=">
Agu 26 11:22:46 infodiginet dockerd[1220]: time="2023-08-26T11:22:46.350034376+07:00" level=info msg=">
Agu 26 11:22:46 infodiginet dockerd[1220]: time="2023-08-26T11:22:46.352870978+07:00" level=info msg=">
Agu 26 11:22:46 infodiginet dockerd[1220]: time="2023-08-26T11:22:46.853738853+07:00" level=info msg=">
Agu 26 11:22:46 infodiginet systemd[1]: Started Docker Application Container Engine.
ramansah@infodiginet:~$ docker --version
Docker version 24.0.5, build ced0996

Step 1: Creating Volume

In this step we will create the volume that Portainer Server will use to store its database, by submitting following command line :

$ docker volume create portainer_data

Output :

ramansah@infodiginet:~$ docker volume create portainer_data
portainer_data

Verify the volume which was created :

$ docker volume inspect portainer_data

Outuput :

ramansah@infodiginet:~$ docker volume inspect portainer_data
[
     {
         "CreatedAt": "2023-08-26T11:29:20+07:00",
         "Driver": "local",
         "Labels": null,
         "Mountpoint": "/var/lib/docker/volumes/portainer_data/_data",
         "Name": "portainer_data",
         "Options": null,
         "Scope": "local"
     }
]

Step 2: Download and install the Portainer Server container

In this step, we will download and install Portainer image on the system. For this purpose we will submit the following command lines :

$ 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-ee:latest

Output :

ramansah@infodiginet:~$ 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-ee:latest
Unable to find image 'portainer/portainer-ee:latest' locally
latest: Pulling from portainer/portainer-ee
772227786281: Pull complete 
96fd13befc87: Pull complete 
5171176db7f2: Pull complete 
a143fdc4fa02: Pull complete 
b622730c7bdc: Pull complete 
c1cad9f5200f: Pull complete 
69ae32ddde08: Pull complete 
4a0d116cdc71: Pull complete 
08962690b30c: Pull complete 
78e44cf728cd: Pull complete 
4f4fb700ef54: Pull complete 
Digest: sha256:656ca138b68f9aaafd0923ad85e89e84d0be7001faa6ff2c9155bbdab0527ae4
Status: Downloaded newer image for portainer/portainer-ee:latest
79492584db6627943211d054eaac1e1e1fadff34bca239c5712c945bbd4099d1

The explanation of each parameters are as follow :

docker run is the base command to start a container
-d means detach. It runs the container in the background.
-p expose UI over port 9000, portainer GUI will be at URL hostname:9000
--name=portainer names the container portainer
--restart=always always restart Portainer (after a crash or at machine or daemon restart)
-v /var/run/docker.sock:/var/run/docker.sock mounts the volume /var/run/docker.sock from the host machine to the Portainer container. /var/run/docker.sock is actually the Docker daemon socket. Portainer needs this socket to get Docker status.
-v portainer_data:/data mounts the volume created previously
portainer/portainer-ce is the name of the Portainer Community Edition image.

Step 3: Verify the Portainer Container

Then we will  verify the Portainer container, by submitting command line below :

$ docker ps

Output :

ramansah@infodiginet:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
79492584db66 portainer/portainer-ce:latest "/portainer" 25 minutes ago Up 10 minutes 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:9443->9443/tcp, :::9443->9443/tcp, 9000/tcp portainer

Step 4: Access Portainer Web UI

So far, the Portainer installation is completed done successfully.  The next step is  log into Portainer Server instance by opening a web browser and open the URL : https://ipaddress_or_hostname:9443.

Portainer CE Web interface

 

Portainer Community Edition web interface is as shown above. To be able to use this application we are asked to enter a license, more detailed information can be seen on the official web Portainer.

Conclusion

Portainer is a powerful tool that simplifies Docker container management, making it accessible to developers at all skill levels. Its user-friendly interface, resource monitoring capabilities, and support for Docker Compose files make it an excellent choice for efficiently managing containerized applications. Whether you’re new to containerization or a seasoned developer, Portainer can help streamline your container management workflows.

(Visited 192 times, 1 visits today)

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *