HTTPD Server Configuration on Docker Container
DOCKER is computer software used for Virtualization in order to have multiple Operating systems running on the same host. Unlike Hypervisors which are used for creating VM (Virtual machines), virtualization in Docker is performed on system-level in so-called Docker containers.
Docker images are the "source code" for our containers; we use them to build containers. They can have software pre-installed which speeds up deployment. They are portable, and we can use existing images or build our own.
Docker containers run in an isolated environment on top of the host's OS. Even if your host runs Windows OS, you can have Linux images running in containers with the help of Hyper-V, which automatically creates a small VM to virtualize the system's base image, in this case, Linux.
Containers are the organizational units of Docker. When we build an image and start running it; we are running in a container. The container analogy is used because of the portability of the software we have running in our container.
In simple terms, an image is a template, and a container is a copy of that template. You can have multiple containers (copies) of the same image.
Step - 1 Install Docker -
URL form where you can download Docker Package
https://download.docker.com/linux/centos/7/x86_64/stable/
Check with this command that YUM is configured on Not -
# yum repolist
(B) Install Docker With YUM -
Most compatible version of Docker is 18 & URL for docker We use in YUM configuration will not resolve latest version dependencies , so use "--nobest" option
# yum install docker-ce -y --nobest
Step - 2 Launch Docker Container -
(A) Start Docker Services -
# systemctl start docker
(B) Pull Docker Image
# docker pull centos
(c) Run Centos Container
# docker run -it --name httpd centos
(d) Install Apache Httpd Web Server Inside Docker Container -
# yum install httpd -y
we have to run apache in foreground: /usr/sbin/apache2 -DFOREGROUND
The .bashrc file is a shell script which is run every time a user opens a new shell.The .bashrc file is a good place therefore to run commands that you want to run every single time you open a shell.To run apache in foreground every single time when we open shell we write the command in .bashrc file
(e) Commit Changes to Image:
# docker commit httpd myhttpdos
Finally, create a new image by committing the changes
(f) export the port on port 8090
# docker run -dit -p 8090:80 --name httpdserver myhttpdos
------------------------------------------------thank you---------------------------------------------------