Configuration of Webserver and setting Python environment on the Docker

suman15
5 min readNov 17, 2020

At first, let us know

WHAT IS DOCKER?

Docker is an open platform for developing, shipping, and running applications. 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.

WHAT IS DOCKER CONTAINER?

A container is a runnable instance of an image. You can create, start, stop, move, or delete a container using the Docker API or CLI. You can connect a container to one or more networks, attach storage to it, or even create a new image based on its current state.

By default, a container is relatively well isolated from other containers and its host machine. You can control how isolated a container’s network, storage, or other underlying subsystems are from other containers or from the host machine. A container is defined by its image as well as any configuration options you provide to it when you create or start it. When a container is removed, any changes to its state that are not stored in persistent storage disappear.

WHAT IS DOCKER IMAGE?

A Docker image is a read-only template that contains a set of instructions for creating a container that can run on the Docker platform. It provides a convenient way to package up applications and preconfigured server environments, which you can use for your own private use or share publicly with other Docker users.

Docker Task Description:
1. Configuring HTTPD Server on Docker Container
2. Setting up Python Interpreter and running Python Code on Docker Container

LETS START!!

[A]. Configuring HTTPD Server on Docker Container

→ INSTALLATION OF DOCKER

For installing the Docker on the top of AWS Redhat

First we have to configure yum.

→ For configuring yum follow the below steps:

YUM CONFIGURED!!

→ Now for installing docker we have to configure docker file

→ Now install docker:

→Here we can see, now docker file is available

# rpm -q docker-ce

→ We can also check by #yum list docker-ce command

→Start the docker services using the below command

#systemctl start docker

→To check the docker status that it is running or not, using the below-mentioned command

#systemctl status docker

→ To know more information of docker use #docker info command

DOCKER INSTALLED & RUNNING ON THE BASE OS !!

→ To download the image on the Base OS:

→ Launch the docker container using the below command

CONTAINER LAUNCHED!!

→ Install the webserver using the below command.

#yum install httpd -y

→ Start your webserver

You could not start your webserver in a regular way

Start with #/usr/sbin/httpd command

→ Create a webpage:

→ Copy your container IP & try to access the webpage:

>> Sometimes while launching our webserver, it gives us security error

So we can use #setenforce 0 command. This command changes SELinux mode from targeted to permissive. In permissive mode, the service is active and audits all actions. However, it does not enforce any security policies.

If it doesn’t work use the below commands :

[B]. Setting up the Python Environment

→ INSTALL PYTHON:

→ PYTHON INTERPRETER:

SUCCESSFULLY COMPLETED!!

THANK YOU FOR READING MY ARTICLE!!

--

--