Install docker on redhat and configure Apache httpd web server on it
For installing docker on redhat you have to first configure yum for it. For this go to /etc/yum.repos.d folder and make a file in it with any name but with .repo extension. Then write as below👇
The url written is 👇https://download.docker.com/linux/centos/7/x86_64/stable/
This is nothing but it contains various versions and packages of doscker.
Now run the commands:-
- yum repolist
- yum install docker-ce — nobest
Yes that's all🤞. docker is installed. the 2nd command install package of docker for your system. something like this you would see👇. press y (yes) to install.
Now, start the services as follows:-
Now, launch a docker container where we can install apache web server in it. lets launch a centos container. But for this we also need centos image of docker. This we can easily find on docker hub. see below👇
So, here you can see the cmd to install centos image which is docker pull centos.
Now run the container and login into it to configure server into it. Follow the below command for this👇
Here you can run any command of redhat or rhel or centos. Now install httpd into it(this is the apache web server). Also, yum is preconfigured here so we can directly give cmd to install as httpd as below👇
press y means yes to install it.
From here the main thing starts. Normally we use command systemctl start httpd to start services and we can use it but here we can’t use it. It gives some error as shown below
But here we can use directly the commands that systemctl runs behind the scene. To get those commands we can see from the base os which is also redhat. so, open a new windows, and install httpd here as above and start services by systemctl start services and then use systemctl status httpd.
so, this is the command → /usr/sbin/httpd and we can directly use this command to start our server. This is also my os i just have changed the resolution today by adding some extra packages to virtual box😅
Now, go to firefox and give the ip of the container and you can see the default page of the apache httpd.
You can find the ip using the command → docker inspect containername👇
you can also put some web page now in it👇
So, finally we have configured web server on docker container like we do in redhat or centos👊. Basically there is only one difference of a command as we directly can’t use systemctl directly here.
If you have any query you can ask me anytime on mail or linkedin😊