How To Install Portainer on Rocky Linux 9
In this tutorial, we will show you how to install Portainer on Rocky Linux 9. Managing containers in a Docker environment can be a challenging task, especially when dealing with complex applications and numerous containers. However, Portainer, an open-source container management tool, comes to the rescue with its intuitive interface and powerful features.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the Portainer on Rocky Linux 9 or RHEL-based.
Prerequisites
- A server running one of the following operating systems: Rocky Linux 9.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Portainer.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Portainer on Rocky Linux 9
Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:
sudo dnf update sudo dnf install dnf-plugins-core
Step 2. Installing Docker on Rocky Linux.
By default, Docker is not available on Rocky Linux 9 base repository. Now run the following command below to add the Docker CE repository to your system:
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
After the repositories have been added to the system, now run the following command to install Docker CE Rocky Linux:
sudo dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin --allowerasing
Once the installation is completed, start the Docker service on your Rocky Linux and also enable it to run automatically with system boot:
sudo systemctl enable docker sudo systemctl start docker
Step 3. Add User to Docker Group.
Add user to Docker group using the command:
sudo usermod -aG docker $USER
Next, create a new group:
newgrp docker
Verify the Docker version is installed:
docker version
Step 4. Installing Portainer on Rocky Linux 9.
With Rocky Linux 9 and Docker set up, let’s proceed with the installation of Portainer using the Command Line Interface (CLI). The following steps will guide you through the process:
sudo docker pull portainer/portainer-ce
Portainer requires a persistent storage volume to store its data. We can create a Docker volume with the following command:
sudo docker volume create portainer_data
Now, let’s run the Portainer container with the appropriate configuration options:
sudo docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
Here’s a breakdown of the command and its options:
-d
: Detaches the container and runs it in the background.-p 8000:8000 -p 9000:9000
: Maps the container’s ports to the host machine, allowing access to the Portainer web interface on port 9000 and the agent on port 8000.--name=portainer
: Specifies a custom name for the container (‘portainer’ in this case).--restart=always
: Configures the container to automatically restart if the server reboots or the container stops unexpectedly.-v /var/run/docker.sock:/var/run/docker.sock
: Binds the Docker socket on the host machine to the container, allowing Portainer to communicate with Docker.-v portainer_data:/data
: Mounts the previously created Docker volume (‘portainer_data’) as ‘/data’ inside the container for data persistence.
Step 5. Accessing Portainer Web Interface.
Once successfully installed, now open your web browser and enter the IP address or domain name of your Rocky Linux 9 server followed by port 9000. For example:
http://your_server_ip:9000
Step 6. Troubleshooting Tips.
While the installation process is relatively straightforward, you may encounter some common issues. Here are troubleshooting tips for some potential problems:
- Unable to Access Portainer Web Interface:
Ensure that the Portainer container is running by executing:
sudo docker ps -a
Check that Portainer is listening on the correct port (9000) using:
sudo netstat -tulnp | grep 9000
Verify that the firewall allows incoming connections on port 9000:
sudo firewall-cmd --zone=public --list-ports
- Incorrect Docker Socket Binding:
Double-check the Docker socket binding command:
-v /var/run/docker.sock:/var/run/docker.sock
- Admin Password Issues:
- If you forget your admin password, you can reset it by removing the Portainer container and data volume, then running the installation steps again.
- Ensure you create a strong password during the initial setup.
Congratulations! You have successfully installed Portainer. Thanks for using this tutorial for installing Portainer on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official Portainer website.