Task — 7.2 Docker task

Srasthy Chaudhary
3 min readMar 14, 2021

In this article, we will configure Apache’s HTTPd server on Docker Container.

Download docker on RHEL8

Lets’ launch a container named os1 form centos image

Install httpd software in the docker container.

In containers, systemctl related commands don’t work for this we have to manually start the service.

First, write one file named index.html in /var/www/html folder

Now start service

Ignore those warnings, here your service is started.

Now to enable httpd service in the container we have to write this same entry into /etc/.bashrc to enable the service permanently.

write new entry /usr/sbin/httpd

Now the service is permanently enabled.

Let us check the output from host os means in RHEL8.

Check container IP and browser it.

Setting up Python Interpreter and running Python Code on Docker Container

Now in the same container which is launched, we will run a Python Program But for that we will first install python3

After installing We created a python file using vi command.

In this python file, we write the code.

After this for running use python3 Task7.2.py. It will initially ask for a password and then the command to run and will run that command in the container using Python.

Thank you!

--

--