Configuring Httpd Server and Setting Up Python Interpreter on Docker Container

Anjaliray
4 min readMar 14, 2021

What is Docker ?

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.

What is Docker Container ?

Docker is a tool by which we manage the container , container is like a operating system you can launch these container with in a second ,docker work on the top of these container’s.

Let’s Start Practical Part -

Step-1) Installation of Docker -

  • First configure docker repository whenever download docker software on base OS. For that we have first go to “/etc/yum.repos.d/”, after that create a repo file for docker software -
cd /etc/yum.repos.d/
vim docker.repo
  • To Install Docker Software in RHEL8 use following command -
yum install docker-ce --nobest
  • Now check the docker version -
docker --version
  • Now Start the Docker Services -
systemctl start docker
  • Now check the docker information using following command -
docker info

Here we can see that there is no image available in docker and none of the container is running.

Step-2) To launch a new container or OS in Docker, we need Docker image.

  • Now pull a Docker Image from Docker Hub.
docker pull 'image_name:version'

Here we can see that there is no image available in docker and none of the container is running.

Step-2) To launch a new container or OS in Docker, we need Docker image.

  • Now pull a Docker Image from Docker Hub.
docker pull 'image_name:version'

Step-3) Now Run a Docker Container using following command -

docker run -it --name 'name_of_container' 'image_name:image_version'
  • Now check that the container is running or not -
docker ps

Step-4) Now check that yum is configured or not inside the container because we want httpd software for configuring apache web-server . For downloading httpd software we need yum command . First we check yum is configured or not -

yum repolist

Here, we can see that yum is already configured in Docker container.

Step-5) Configuration of Web server

  • To Launch the httpd server run following command -
  • Now Start the httpd service but systemctl command doesn’t support in docker container. So we will use /usr/sbin/httpd to start httpd-
/usr/sbin/httpd

Step-6) Now create a web page inside the container. For that go inside ‘/var/www/html/ folder then create a web page.

cd /var/www/html
vim index.html

Step-7) Install the net-tools software in Docker Container.

yum install net-tools
  • Now check the IP of the Docker Container.
ifconfig

Step-8) Now run this web page using following command.

curl 'ip_of_container/page_name'

Here we can see that web page is running Successfully !!

Step-9) Configuring Python Interpreter -

  • First, we have to install the python3 inside the Docker Container. Use following command to install python3
yum install python3
  • Now check python3 is installed or not. For this Check the version of python using following command-
python3 -V
  • Now use Python3 REPL Interpreter to execute python code.

Here this Python Interpreter is working.

In this way Task is Completed Successfully !

Thank u

--

--