HTTPD Server On DOCKER Container



What is Docker?



Docker is an open source containerization platform. Docker enables developers to package applications into containers—standardized executable components that combine application source code with all the operating system (OS) libraries and dependencies required to run the code in any environment.
While developers can create containers without Docker, Docker makes it easier, simpler, and safer to build, deploy, and manage containers. It’s essentially a toolkit that enables developers to build, deploy, run, update, and stop containers using simple commands and work-saving automation.

What are Containers?

The main goal of software development is to keep applications isolated from one another on the same host or cluster. This is difficult to achieve, thanks to the libraries, packages, and other software components needed for them to run. One solution to this problem is containers, which keep the application execution environments isolated from one another but share the underlying OS kernel
They provide an efficient and highly granular mechanism to combine software components into the kinds of application and service stacks required in a modern enterprise, and to keep those software components updated and maintained.

Containers offer all the benefits of Virtual Machines, including application isolation, disposability, and cost-effective scalability. 

But the additional layer of abstraction (at the OS level) offers important additional advantages:

  • Lighter weight                                       
  • Greater resource efficiency                   
  • Greater efficiency
  • Better application development
  • Improved developer productivity           

                               

Why use Docker?

The benefits of using Docker are:

  • Offers improved and seamless productivity: Docker containers can be run on any data center, desktop, and cloud environment without any modifications.
  • Automated container creation: Automatically builds a container based on application source code.
  • Container reuse: Containers can be reused as base images(templates) 
  • Shared container libraries: Open-source Registry can be accessed developers which include thousands of user-contributed containers.
  • Container versioning:  Version tracking of a container image can be done using Docker and it can also be rolled back to older versions.
  • Fast and consistent delivery of applications: Docker’s streamline the development lifecycle by making developers work in a standardized environment with the use of local containers that provide the applications and services. Containers are very useful for continuous integration and continuous delivery workflows.
  • Responsive deployment and scaling: Docker supports portable workloads, and its lightweight nature also makes it easy to manage dynamic workloads by scaling up applications and services in real-time.
  • Runs more workloads on the same hardware: Docker provides a viable and cost-effective choice for hypervisor-based virtual machines and also it’s perfect for high-density environments and for small and medium deployments.

HTTPD Server on Docker Container :



To configure HTTPD server on Docker Container, we need these simple steps:

  1. Install docker
  2. Start Docker Service
  3. Pull OS image
  4. Run Docker Container
  5. Install HTTPD in that Container
  6. Put Code in Document Root
  7. Start HTTPD services

1. INSTALL DOCKER

To install docker, First we need to configure yum.
For this we need to create a repository for docker in yum.repos.d

In /etc/yum.repos.d/   we have to create a file :




Now yum is configured for docker.
We can install docker :


Docker is installed. Now we have to start docker Service 


2. Start docker Service :


3. Pull OS Image :


4. Run Docker Container :


5. Install Apache Web Server in Docker Container:




Here we can see that our apache web server has been installed.

6. Put Code in Document Root :



7. Start HTTPD Service :

At last we have to start HTTPD service in docker container.
For this we can't do directly using systemctl because systemctl command is by default not supported in docker container.

For any command/ any program, there are some other commands running in the background. 

Here for systemctl for httpd, the command running in the background is /usr/sbin/httpd.
We can run this command in our docker container to start httpd.



So that's all we had to do!!

We have successfully created a webpage on the top of Docker Container.


Comments

Post a Comment

Popular posts from this blog

Automation Using Python

Chat Server using UDP

NETWORK TOPOLOGY