Docker is a software platform for building applications based on containers — small and lightweight execution environments. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly.

On the other hand a Docker container image is an executable package of software that includes a lot of different things to run like code, runtime, system tools, system libraries and settings.

To perform this task a system must have docker installed. We can check running container using :

docker ps

First we create a container :

docker run -it — name name_of_container imagename

Now we install httpd server on our Container.

yum install httpd

After installing we have to start the server and then enable it for which we use

Systemctl start httpd
Systemctl enable httpd

So we start our server using :


we can check our service and its port using :

netstat -tnlp

and also we put a webpage to serve in /var/www/html folder.

But After starting if we close our container and then again start it httpd service stops. Its because httpd service is not enabled.

So to make our httpd service permanent we have to make it start every time we start our container and for that we can write its start Command in the script file which always runs on starting the os.


We write /usr/sbin/httpd Command in .bashrc file but then again if we start our container our httpd service doesn’t run its because when we start our httpd service it creates some files for this service with unique pid and when we close our container these files still remain in that location and when we again restart our container and service they can’t create new files. So we have to delete those files while restarting our service

rm -rf path_of_files

so we put both commands in .bashrc file.

Now we can see our service is running and we can access the webpage and see the content.

Python Interpreter in Container :

To run a python interpreter inside a container we first create a container and run following command

yum install python3

and to use the interpreter we can run :


Which gives us a REPL to perform our tasks.

So now we have created two containers one with a httpd service running and another with a python interpreter.



TASK #7.2



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store