Configuring httpd server on docker container, Setting up Python interpreter and running python code on docker container

Configuring httpd server on docker container, Setting up Python interpreter and running python code on docker container

I have pre-installed docker container on rhel version_8.0 having docker version docker-3.18

a.) Configuring httpd server on docker container.

  1. To start the docker engine on rhel8, command: systemctl start docker
No alt text provided for this image

2. Pulling a centos image from the docker hub:

No alt text provided for this image

3. Launching a new container on the top of the docker engine, command: docker run -it --name web1 centos:latest

Name of the launched OS: "web1", id: "707981bffce3"

No alt text provided for this image

4. Now, we will install package name "net-tools" for "ifconfig" command/program, using the command: yum install net-tools -y

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

5. Now, we will install HTTPD software, using command: yum install httpd -y

No alt text provided for this image
No alt text provided for this image

6. Now, we will run the command "netstat -tnlp" to check the service has started with default port no:80 or not

No alt text provided for this image

As we can see that no service has been started...

7. To start the service httpd, in simple OS, we generally use the command "systemctl start httpd", but it's not in the case of docker, systemctl isn't there in docker.

So, to start the service, we have to run the full path of the full path of the command from where the particular service will start, In this case command: /usr/sbin/httpd

No alt text provided for this image

8. Now, again run netstst -tnlp command:

No alt text provided for this image

we can see that httpd service has been started..

9. Now, we will create a html file inside /var/www/html folder named "webserver.html"

No alt text provided for this image
No alt text provided for this image

10. to see the ip of the system, command "ifconfig":

No alt text provided for this image

11. Using the curl command from the base OS to check that httpd server has been configured successfully.

No alt text provided for this image


b.) Setting up Python interpreter and running python code on docker container

  1. Again start the same OS with the help of the id
No alt text provided for this image

2. Now run the following command to check whether the python is installed or not, and the package is present in the repository or not, command: "yum repolist python3"

No alt text provided for this image

3. Now, run the following command to install the python:

No alt text provided for this image
No alt text provided for this image

4. Now, run the command "python3", to write a program as in live interpreter

No alt text provided for this image

5. Now, run a python code, e.g. print("python interpreter installed successfully")

No alt text provided for this image

OUR HTTPD SERVER HAS BEEN CONFIGURED SUCCESSFULLY AND PYTHON CODE IS RUNNING SUCCESSFULLY, HERE THE TASK ENDS....

To view or add a comment, sign in

More articles by Kapil Kumar

  • Creating a Simple Calculator with flutter

    I have used flutter to create a simple calculator app which can perform operations like +,-,*,/ Here, I will show you…

  • Docker Web Portal

    I have created a web portal related to docker, in which we can run docker commands..

  • Object Recognition and License plate detection with recognition

    I have created a machine learning mode: Object Detection. ---> Main objective is to detect the car.

  • Use case of Javascript : Uber

    I am doing this article on Uber company..

  • Kubernetes GUI(Web Portal)

    I have created a K8s GUI with my team members in summer training. It will run some of K8s commands for you, like:…

  • k-mean clustering and its real usecase in the security domain

    K-means clustering is one of the simplest and popular unsupervised machine learning algorithms. Typically, unsupervised…

  • Task 04

    Task 4.1: Create image by yourself Using Python Code Above is the code in which I have created "smiley face" and "sad…

  • IDS, Cyber crimes and confusion matrix

    Firstly, I will talk something about IDS(Intrusion Detection System). Intrusion Detection System is a software…

  • GUI container on the Docker

    I have already installed docker Going inside a particular folder or workspace, I will create a Dockerfile, to build an…

  • Creating a very simple ML model on Docker container

    Pulling the Docker container image of CentOS image from DockerHub 2. Creating a new container, using the following…

Others also viewed

Explore content categories