Configuring web server and setting up python interpreter on the top of docker container

Configuring web server and setting up python interpreter on the top of docker container

Docker & Docker Containers

 Docker is a containerization platform that packages your application and all its dependencies together in the form of a docker container to ensure that your application works seamlessly in any environment. 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.

Docker Container is a standardized unit which can be created on the fly to deploy a particular application or environment. It could be an Ubuntu container, CentOs container, etc. to full-fill the requirement from an operating system point of view. Also, it could be an application oriented container like CakePHP container or a Tomcat-Ubuntu container etc. It leveraged existing computing concepts around containers and specifically in the Linux world, primitives known as cgroups and namespaces. Docker's technology is unique because it focuses on the requirements of developers and systems operators to separate application dependencies from infrastructure.

?? TASK DESCRIPTION :

??Configuring HTTPD Server on Docker Container

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

First, Configuring HTTPD Server on Docker Container--

Step 1 : Installing the docker first

Command : yum install docker-ce --nobest
No alt text provided for this image

Step 2 : Starting the docker services

Command : systemctl start docker

No alt text provided for this image

Docker services started--

Command : systemctl status docker

No alt text provided for this image

Step 3 : Pulling the image - For launching the container, we need to pull the image. Here we are pulling centos image

Command : docker pull centos

No alt text provided for this image

Step 4 : Launching the container with centos image

Command : docker run -it --name <container_name> <image_name:image_version>

No alt text provided for this image

Step 5 : Installing httpd software on the top of container

Command : yum install httpd

No alt text provided for this image

Step 6 : Creating a html file named page.html in the /var/www/html folder

No alt text provided for this image

Step 7 : Starting httpd services

We can check whether the services started or not by running netstat -tnlp command. For running this command we need to install net-tools software.

No alt text provided for this image

Generally, "systemctlcommand is used for starting services but "systemctl" command is not supported in containers. So no service started with port 80. This can be seen by running the Command : netstat -tnlp

No alt text provided for this image

So "/usr/sbin/httpdcommand is used for starting the httpd services in the docker container.

No alt text provided for this image

Now, httpd services started with port 80.

Step 8 : Deploying the html file on the browser

No alt text provided for this image

URL : https://172.17.0.2/page.html

No alt text provided for this image

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

Step 1 : Installing the python software

Command : yum install python3

No alt text provided for this image

Step 2 : Creating and running python code inside the container

  • Python interpreter can be launched by running the Command : python3, here you can run any python code. Also can create a python code file inside the container and can run it using the Command : python3 <filename>
No alt text provided for this image
  • Another way is that you can create a python code file inside the container and then create the image of this container. So this container image will already contain the python code file. So now can directly run this python code file using the python3 command while launching a new docker container with this created image.

Creating image of the launched container which already contains the python file--

Command : docker commit <container_name> <image name:version>

No alt text provided for this image

The image "myhttpd_image" created, can verify by the Command : docker images

Now, directly running the python code file while launching a new container with the created image- "myhttpd_image".

Command : docker run -it --name <container_name> myhttpd_image:v1 python3 <filename>

No alt text provided for this image

It gives the output of the python file.

Thank You for reading..!!






要查看或添加评论,请登录

Harshita Kumari的更多文章

  • K-means Clustering and its use-case in the Security Domain

    K-means Clustering and its use-case in the Security Domain

    What is K-means Clustering? K-means clustering is one of the simplest and popular unsupervised machine learning…

    5 条评论
  • Industry Usecase of JavaScript

    Industry Usecase of JavaScript

    INTRODUCTION JavaScript is a lightweight, cross-platform, and interpreted scripting language. It is well-known for the…

    4 条评论
  • Confusion Matrix - IDS

    Confusion Matrix - IDS

    WHAT IS CONFUSION MATRIX? A Confusion matrix is an N x N matrix used for evaluating the performance of a classification…

    4 条评论
  • Industry Use Case of Jenkins

    Industry Use Case of Jenkins

    WHAT IS JENKINS?? It is a free and open source automation server. It helps automate the parts of software development…

  • INDUSTRY USECASES OF OPENSHIFT

    INDUSTRY USECASES OF OPENSHIFT

    What is OpenShift? OpenShift is a commercialized containerization software product created from an open-source project…

  • MTV using MongoDB

    MTV using MongoDB

    What is MongoDB? MongoDB is an open-source document-oriented database. It is used to store a larger amount of data and…

  • Industry use case on Artificial Neural Network

    Industry use case on Artificial Neural Network

    The developers always try to relate the technology with the real world i.e the artificial neural networks have been…

    1 条评论
  • Case Study and Industries Use-cases of Amazon SQS!

    Case Study and Industries Use-cases of Amazon SQS!

    In this Blog we’re going to discuss about the SQS Service of AWS with its use cases What is Amazon SQS? Amazon Simple…

  • Azure Kubernetes Service (AKS)

    Azure Kubernetes Service (AKS)

    Kubernetes Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and…

  • Increase or Decrease the Size of Static Partition in Linux

    Increase or Decrease the Size of Static Partition in Linux

    ?? Task Description ?? 7.1: Elasticity Task ??Increase or Decrease the Size of Static Partition in Linux.

社区洞察

其他会员也浏览了