Table of Contents
#Introduction
In this tutorial, I will use Docker to install an apache web server. How to set up Apache web server in a Docker container. Now, let go Docker install Apache Web Server.
Docker as a platform container. I will install Docker on Debian/Ubuntu and install Apache 2.4 container from Docker Hub.
Install Docker on Ubuntu here
Setting up the Apache Docker Container
For example, I will install Apache 2.4 container named devops-roles. Use an image called httpd:2.4 from Docker Hub. and detached from the current terminal.
Host port is 8080 to be redirected to guest port 80 on the container. I will serve a simple web page form /home/vagrant/website.
Docker install Apache web server
docker run -itd --name devops-roles -p 8080:80 -v /home/vagrant/website/:/usr/local/apache2/htdocs/ httpd:2.4
Check Docker Apache container running as command below
docker ps
To created index.html file inside /home/vagrant/website directory.
sudo vi /home/vagrant/website/index.html
The content as below
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Learn Docker at DevopsRoles.com</title>
</head>
<body>
<h1>Learn Docker With DevopsRoles.com</h1>
</body>
</html>
Open web browser type server-ip:8080/index.html
The output terminal as below
Now, you can stop docker container apache
docker stop devops-roles
and remove it:
docker rm devops-roles
You can clean up and delete the image that was used in the container.
docker image remove httpd:2.4
Via Youtube
Conclusion
You have to Docker install Apache Web Server. I hope will this your helpful. Thank you for reading the DevopsRoles page!