Configuring HTTPD webserver & Setting up Python Interpreter and running Python Code on Docker Container

What is Docker ?

Docker is an open-source technology used mostly for developing, shipping, and running applications. With it, you can isolate applications from their underlying infrastructure so that software delivery is faster than ever. Docker’s main benefit is to package applications in “containers,” so they’re portable for any system running the Linux operating system (OS) or Windows OS. Though container technology has been around for a while, the hype around Docker’s approach to containers has moved this approach to the mainstream as one of the most popular forms of container technology.

What is Docker Container ?

A Docker container, as partially explained above, is a standard unit of software that stores up code and all its dependencies so the application runs fast and reliably from one computing environment to different ones. A Docker container image is a lightweight, standalone, executable package of software that has everything you need to run an application — code, runtime, system tools, system libraries, and settings.

🔅Configuring Docker in RHEL:

Firstly we have to install docker in our system. To install docker we use the command yum install docker-ce . To install docker yum needs a repository to install any software or packages. For that we have first go to /etc/yum.repos.d/, and create a repo file for docker software.

  1. cd /etc/yum.repos.d/
  2. vim docker.repo

Now we have to install docker using following commands: yum install docker-ce — nobest

To check the docker version using command: docker — version

After installation of docker, To start Docker Service using following command: systemctl start docker

To check the docker information using following command: docker info

Here we can see there is no image available in docker and none of the container is running. To launch a new container or OS in Docker, we need Docker image.

Now pull a Docker Image from Docker Hub using following command: docker pull ‘image_name:version’

To check the available images in docker using following command: docker images

To run a Docker Container using following command: docker run -it os_name:os_version

and To install httpd webserver using following command: yum install httpd

To start the httpd service but systemctl command doesn’t support in docker container. So we will use command to start httpd is : /usr/sbin/httpd

Now create a web page inside the container. First run this cd /var/www/html to go Document root directories. Here we create a web page task7.2.html

Install ifconfig command software. In docker container ifconfig command is not available we have to install that using software which name net-tools we use command to install ifconfig command is yum install net-tools

Now we check the IP of the Docker Container using ifconfig command.

Now we see web page in the browser using IP address/filename

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

First we have to install the python3 inside the Docker Container. Use following command to install python3 is yum install python3

To check python3 is installed or not using following command: python3 — version

Now we use Python3 REPL interpreter to execute python code.

Thank You for Reading.

--

--

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