Docker install Apache Web Server

#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
Docker install Apache Web Server

Check Docker Apache container running as command below

docker ps
docker ps command

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

check apache

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!

,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.