How to use docker as a web server
Step 1: — Create a repo file to install docker community edition
vi /etc/yum.repos.d/docker.repo
step 2 : — install docker in our system
Step 3 : —Download centos docker image
Step 4 : — Start services of docker
Step 5 : — Launch Docker container with centos docker image
hear we use -p for patting so we can also use the services of docker outside the RHEL8
- -i for launch container in interactive mode
- -t for provide terminal (tty)
— name argument use for give the name of docker OS
Step 6 : — Install apache httpd package in the docker image
Step 7 : — Start the service of web server
In docker we can’t use systemctl cmd for start services of any services because docker not boot it only used shared resources of docker host (RHEL8)
Step 8 : — Create an index.html file in /var/www/html/ directory
/var/www/html is default document directory of apache web server
Final Output
<ip of RHEL8 OS>:<port number which is initialize at time of launching container>
Run Python Program in docker image
Step 1: — Install python3 package in docker os
Step 2 : — Write a simple python program
Step 3 : — Run python program
Thank you