1: Configuring the Webserver On a Docker Container

In this article, we will be discussing about how to install and configure HTTPD WebServer on a Docker Container Image

For this tutorial, I have launched an instance in AWS Cloud. The Instance Image is Amazon Linux 2. On the top of it, I installed docker using "yum install docker" command. As the repo's are already configured in Amazon Linux, it will directly be downloaded and installed.

[root@ip-172-31-40-189 ~]# docker --version
Docker version 19.03.13-ce, build 4484c46

After the docker is installed, we will now build an image using Dockerfile.

The Dockerfile looks like this

  • FROM centos:latest
  • RUN yum install httpd -y
  • CMD /usr/sbin/httpd
  • expose 80/tcp
  • COPY workspace/html_files/index.html /var/www/html/

For building the image, we simple need to go to the directory where Dockerfile is located and run the following command:

docker build . -t httpd:v1

This will create an image named "HTTPD" and version/tag as "v1"

We now just need to create a container using this image, everything is already specified in the Dockerfile. NOTE: while running the image we need to assign the webserver port to the host OS with the help of -p option.

  1. docker run -it -p 8080:80 --name myweb1 httpd:v1

This will create a container and run the container with the specification in the Dockerfile.

And now you can simple type hostip:8080 in any web browser and you can see the content available in the index.html file

No alt text provided for this image

Content in the Index.html file:

No alt text provided for this image

Thus we have successfully setup webserver running on a docker container os


2: Setup Python Interpreter on a Docker Container

For this we simple need to create an image(im using centos:7) and install Python using yum command (or we can also specify this in the Dockerfile using CMD yum install python3 -y)

The command to run in Container is:

yum install python3

We can run everything on python just as we do with python in a regular OS

To view or add a comment, sign in

More articles by Charan V.

  • K Means Clustering UseCases in Security Domain

    Introduction K Means Clustering is an Unsupervised Machine Learning. It is one of the simplest and popular unsupervised…

  • Deploying a ML model inside Docker

    In this blog, we'll be talking about deploying a trained Machine Learning Model inside a Docker Container. So, for…

    2 Comments
  • Integrating LVM with Hadoop

    Hey Everyone, in this article we will learn how we can provide elasticity to our datanode's storage. First of all, we…

  • A Network Setup, Ping ONE but not the OTHER

    Hello Everyone, In this Article, we will setup a network such that it will ping to Google servers, but it will not ping…

  • AWS CLI Infrastructure and Using CMD to launch and manage Instances

    Here, in this post, I'll let you know how to use aws-cli to launch and manage AWS services with very ease. Today, I…

  • What is BigData in Layman's Language

    BigData Problem Hey Everyone.! So I've just started a research on data like how much data does same company works per…

Explore content categories