Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating-system kernel and are thus more lightweight than virtual machines.
Portainer is a lightweight management graphical user interface which allows you to easily manage your Docker host or Swarm cluster. Portainer is meant to be as simple to deploy as it is to use. It consists of a single container that can run on any Docker engine. It’s a powerful, open-source management toolset that allows you to easily build, manage and maintain Docker environments
In this guide you will learn that how to install docker and manage it with portainer.
Install Docker on CentOS 8 / RHEL 8
Step 1 Enable Docker CE Repository
Currently docker packages are not available on CentOS and RHEL 8 repositories, so run following dnf command to enable Docker CE repository.
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
Step 2 Install Docker CE using dnf command
Now, use below dnf command to install latest version of docker.
dnf install docker-ce --nobest -y
Step 3 Start Docker Service
After the installation, start and enable docker service using the following systemctl commands
systemctl start docker
systemctl enable docker
systemctl status docker
Step 4 Verify and Test Docker CE Engine
To verify that docker ce engine has been setup correctly, run below docker command,
docker run hello-world
Docker has been installed successfully and running fine, now we will install and configure portainer so that we can manage docker from web interface.
Install Portainer on CentOS 8 / RHEL 8 for Docker Management
Step 1 Download Portainer Image
Download the Portainer image from the DockerHub using the docker pull command below.
docker pull portainer/portainer
Step 2 Run Portainer
Run the Portainer container with the following command:
docker run -d -p 9000:9000 --name your_portainer_name --restart always -v /var/run/docker.sock:/var/run/docker.sock -v /opt/portainer:/data portainer/portainer
Step 3 Verify Portainer is Running
After installing the Portainer container, run the docker ps command to verify the status of the container:
Step 4 Access Portainer Web Interface
Now, open your browser, access the Portainer web interface with your server’s IP or FQDN with port 9000
In my case it is 192.168.231.130:9000
Note: If you are facing any issue or unable to browse the link just use below commands
firewall-cmd --permanent --zone=trusted --change-interface=docker0 firewall-cmd --permanent --zone=trusted --add-port=4243/tcp firewall-cmd --reload
Next we need to set admin username and password to access portainer. Then, click on “Create User” button to create your administrator user.
Step 5 Configure Portainer
We will configure Portainer to “manage the local Docker environment” select Local Docker environment and click on the Connect button
Finally, you will be redirected to the Portainer dashboard, select the “local docker”
Here you can see all info and a summary about your containers, images, networks, volumes and Templates.
Finally everything has been done and now you can create, manage and remove your docker containers from portainer graphical interface.
After logging in portainer you will be redirected to the Portainer home screen, select the “local docker” then go to the “Dashboard” here you will see running stacks, containers, images, volumes and networks.
Click on the stacks option and it will provide status of all created stacks.
This list will provide details of all running and stopped container. This output is very similar to docker ps command option.
Clicking on this option will provide the host of container images that are available. It will show all the container images.
It is used for network operations. Like assigning IP address, creating sub-nets, providing IP address range and user access control.
Create a Container Using Portainer GUI
There are many other features you can explore by yourself. Now we will create a docker container. we will create Apache container.
Under Add Templates option, Click on “Httpd” template
Now set the Name for container, leave network as it is, then configure its ports and click on “Deploy the container” button.
Now you can verify the status of created container from “Containers” option. you can see in image below that container named “my-apache-server” is running
Test Apache is running fine. open your browser and browse your SERVER-IP-ADDRESS
That’s it in this article, I hope this will be very helpful.