Launching Webserver and Python Interpreter On Docker Container

Docker is an open-source containerization software that creates isolated environments to run an application. 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.

Installation :

Task :

  • Setting up Python Interpreter and running Python Code on Docker Container

Configuring Httpd Server :

  • To download the Docker Image used as base image for the Container docker has Command as :
docker  pull  {image_name}
  • To launch any Docker Container docker has following command (This command will download the image automatically) :
docker run --flags --name {name_of_container} {image_name}
  • Launch the docker container using base CentOS Image by Running the Command as:
docker run -it --name sar_os -p 9091:80 centos

The above command includes the flags as :

  • -i flag launch the container in interactive mode
  • -t flag gives a terminal as container boots up.
  • -p option maps the host’s 80 port with 9091 port of Docker Container .

2) As we are inside the container we have to Install HTTPD Package for Configuring Webserver .

yum install httpd -y
  • Finally the Webserver is successfully configured inside docker container. To test the Webserver write a simple html code inside /var/www/html
  • To access the Apache Webserver content inside Docker Container we have to use <public_ip of host>:9091/home.html
Check the IP of host using : ifconfig enp0s3

Installing Python3 Inside Docker Container

yum install python3 -y
  • Cheking python3 is correctly installed
  • To exit container type exit

I’m an undergraduate student at IIIT Ranchi, pursuing my B-Tech in Electronics and Communication Engineering.