ARTH Task 7.2

Naveen Pareek
5 min readMar 14, 2021

Description:

🔅Configuring HTTPD Server on Docker Container
🔅Setting up Python Interpreter and running
Python Code on Docker Container

Before discussing about the task. Let first discussing about Docker Container

What is Docker?

Docker is a set of Platform as a Service (PAAS) product that uses 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.

Docker Architecture:

Docker uses a client-server architecture. The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers. The Docker client and daemon can run on the same system, or you can connect a Docker client to a remote Docker daemon. The Docker client and daemon communicate using a REST API, over UNIX sockets or a network interface. Another Docker client is Docker Compose, which lets you work with applications consisting of a set of containers.

Docker Architecture

What are the Benefits of Docker Containers?

Docker containers are popular now because they have Virtual Machines beat. VMs contain full copies of an operating system, the application, necessary binaries, and libraries — taking up tens of GBs. VMs can also be slow to boot. In contrast, Docker containers take up less space (their images are usually only tens of MBs big), handle more applications, and use fewer VMs and Operating Systems. Thus, they’re more flexible and tenable. Additionally, using Docker in the cloud is popular and beneficial. In fact, since various applications can run on top of a single OS instance, this can be a more effective way to run them.

Another distinct benefit of Docker containers is their ability to keep apps isolated not only from each other but also from their underlying system. This lets you easily dictate how an allocated containerized unit uses its system resources, like its CPU, GPU, and network. It also easily ensures data and code remain separate.

A Docker container runs on any machine that supports the container’s runtime environment. You don’t have to tie applications to the host operating system, so both the application environment and the underlying operating environment can be kept clean and minimal.

Most business applications consist of several separate components organized into a stack — a web server, a database, an in-memory cache. Containers enable you to compose these pieces into a functional unit with easily changeable parts. A different container provides each piece so each can be maintained, updated, swapped out, and modified independently of the others.

Here, I’ll not discuss the installation part of Docker. But, I’ll discuss some basic commands that we need to configure this task.

Commands are-

o docker pull :- command used to download docker images from docker container registry.

o docker images :- command used to display all the images currently installed on the system.

o docker ps :- command used to list the containers.

o docker create :- command used to launch new container

o docker rm :- command used to remove one or more container.

o docker kill :- command used to kill the running container.

Now comes to the task and follow the steps:

The first task is to configure the web server in a docker container:

Step1:- Check whether docker is running or not, using the command

Ø systemctl status docker

Step2:- Run new docker container using centos image and the cmd is

Ø docker run -it –name web_server centos:latest

Step3:- Now after launching the new docker container check whether httpd is installed or not in it, using cmd

Ø rpm -q httpd

Step4:- If s/w is not installed then install it using cmd

Ø yum install httpd -y

Step5:- Now Create webpages in root directory folder of httpd

Ø cd /var/www/html/

Step6:- Now start the httpd service in the docker container. As systemctl won’t support in the container. So, we need to follow another approach that is-

Ø /usr/sbin/httpd

Step7:- Now check whether the service is started or not. For this we need IP Address of container. As ifconfig command is not installed in container. So, firstly we need to install it using command

Ø yum install net-tools

Step8:- Verify the service using curl command from baseOS with help of containerIP.

As we successfully completed the first part of the given task. Now, start the second task.

In the second task, we have to install the python interpreter in the docker container and then execute python code in it.

Steps are shown directly via pictures attached below:-

Task Successfully Completed.

Thank You

Keep Learning & keep growing

--

--