Configuring APACHE/HTTPD Server on Docker Container

DOCKER :

Docker is a platform for developers and sysadmins to develop, deploy, and run applications with containers. This is often described as containerization. Putting applications into containers leads to several advantages like:

  • Docker containers are always portable. This means that you can build containers locally and deploy containers to any docker environment (other computers, servers, cloud, etc …)
  • Containers are lightweight because containers are sharing the host kernel (the host operating system) but can also handle the most complex applications.

To install docker on Red Hat Enterprise Linux 8 please visit below link

After installing we have to start docker services. For that run command as ‘# systemctl start docker’. After this see the status using command ‘# systemctl status docker

Here docker runs on my Redhat OS so it called as host for docker.

Now run command ‘# docker info’. It gives you detailed information about the installed version and more information about Docker Container Engine running on your machine.

To see all list of already existing Docker images go to hub.docker.com.

To list the Docker Images present in your local machine, you can run this command : ‘# docker images’

When we install docker there is no docker images present so we have to download it from Docker Image Registry.

Here we use docker image for CentsOS & we can get it by using command as ’# docker pull centos’. It will download latest version of centos. After downloading we can check it using command : ‘# docker images’

After image download we have to install it. For that use command ‘# docker run -it — name <name of os> <name of image : version>

Now we are landed inside the Docker Container.

In this container yum is already configured.

For this task I need IP of of container. By using ‘# ifconfig’ we can get it. But there is no command ‘# ifconfig’.

Every command is come from some software. We can get name of software using command ‘# yum whatprovides <name of command>.

Now we can install it using command ‘# yum install net-tools’

Now we can get IP using command ‘# ifconfig’

Installation of HTTPD :

After this we install apache server using command ‘# yum install httpd’

After installing we have to start httpd services using command ‘# /usr/sbin/httpd’. Default port number is 80 so we can check this using command ‘# netstat -tnlp’

Now go to folder ‘/var/www/html/’ and create one html file. Write some simple code in that file and save it.

Now we can access this file from remote system by using IP of container as

‘IP of container/name of file’

Web server is successfully configured.