How to Run Container from Portainer in Linux CentOS 8 Virtual Server

Posted on

Introduction

This is another article which is the continuation from several previous articles. Those are the article with the title of ‘How to Install Portainer in Linux CentOS 8’ in this link. Another article is another one with the title of ‘How to Access Portainer running in a virtual server using Linux CentOS 8’ in this link. After installing and also accessing it, the next step is just to run a container from it.

Running a Container from a portainer in Linux CentOS 8 Virtual Server

How to Run Container from Portainer in Linux CentOS 8 Virtual Server
How to Run Container from Portainer in Linux CentOS 8 Virtual Server

The context in this article is to run a container from a portainer. The portainer is also running as a container by docker tool. The portainer is running in a virtual server. Although the portainer running in port 9000 inside a guest machine, the port forwarding rule definition in the host machine is using port 8000. After successfully installing the portainer and accessing it, the following display will appear :

After that, just access the local button in order to manage a local Docker environment. The following image will appear :

How to Run Container from Portainer in Linux CentOS 8 Virtual Server
How to Run Container from Portainer in Linux CentOS 8 Virtual Server

Next step, just click the Connect button, the following page will appear :

How to Run Container from Portainer in Linux CentOS 8 Virtual Server
How to Run Container from Portainer in Linux CentOS 8 Virtual Server

Click the local endpoints, the following image will appear :

How to Run Container from Portainer in Linux CentOS 8 Virtual Server
How to Run Container from Portainer in Linux CentOS 8 Virtual Server

Finally, in order to run a new container, just click on the Containers link in the center. The following list of the available containers will appear as in the following image below :

How to Run Container from Portainer in Linux CentOS 8 Virtual Server
How to Run Container from Portainer in Linux CentOS 8 Virtual Server
How to Run Container from Portainer in Linux CentOS 8 Virtual Server
How to Run Container from Portainer in Linux CentOS 8 Virtual Server

Actually, the above image is listing the already created container with the name of ‘apache’. It does not have the container with the name of ‘apache’ earlier. Just click the + Add Container as in the image above, in order to add a new container. Soon after, the following page will appear in the image below :

In the above there is a field with the label of Name. Fill it with the name of the container. In the above example, it is using ‘apache’ as the container’s name. It is because it will try to create a running container of Apache Webserver. The next one is to specify the image name available from the docker.io. In this context, since there is a need for an Apache Webserver image, just specify the value of ‘httpd:latest’. It means, just download the latest version of the Apache Webserver’s image. Following after click the network port publishing to fill the Manual network port publishing. Since by default, Apache Webserver is running in port 80, just define the host port is 80. Furthermore, just define the port’s container is 80. Do not forget to choose the TCP option as the protocol. Apparently, there are several option configurations below :

How to Run Container from Portainer in Linux CentOS 8 Virtual Server
How to Run Container from Portainer in Linux CentOS 8 Virtual Server

Do not forget to click the Restart policy and then select ‘Always’ for the value. After that, click the Deployment button. Right after, it will try to deploy the container and then run it directly. If it is a success, there will be a listing of the container where one of that is the ‘apache’. So, in order to verify whether Apache Webserver’s container is currently running or not, just access it from the host machine. The following is the output where the Apache Webserver’s service is alive and it is presenting the following page :

How to Run Container from Portainer in Linux CentOS 8 Virtual Server
How to Run Container from Portainer in Linux CentOS 8 Virtual Server

In this case, in order to access the Apache Webserver’s container running in the portainer just access the URL address is http://localhost:9980 from the web browser. Why is not http://localhost instead ?. The reason is because there is a port forwarding rule from the host machine to the guest machine.

Leave a Reply