Docker: Apache install

From OnnoWiki
Revision as of 07:33, 25 June 2020 by Onnowpurbo (talk | contribs) (Created page with "Sumber: https://www.tecmint.com/install-apache-web-server-in-a-docker-container/ One of the amazing things about the Docker ecosystem is that there are tens of standard cont...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Sumber: https://www.tecmint.com/install-apache-web-server-in-a-docker-container/


One of the amazing things about the Docker ecosystem is that there are tens of standard containers that you can easily download and use. In the following example we will instantiate an Apache 2.4 container named tecmint-web, detached from the current terminal. We will use an image called httpd:2.4 from Docker Hub.

Our plan is to have requests made to our public IP address on port 8080 be redirected to port 80 on the container. Also, instead of serving content from the container itself, we will serve a simple web page from /home/user/website.

We do this by mapping /home/user/website/ on the /usr/local/apache2/htdocs/ on the container. Note that you will need to use sudo or log in as root to proceed, and do not omit the forward slashes at the end of each directory.


sudo docker run -dit --name tecmint-web -p 8080:80 -v /home/user/website/:/usr/local/apache2/htdocs/ httpd:2.4
sudo docker run -dit --name tecmint-web -p 8080:80 -v /home/onno/website/:/usr/local/apache2/htdocs/ httpd:2.4


Cek

sudo docker ps

Buat File HTML Sederhana

vi /home/user/website/docker.html
vi /home/onno/website/docker.html


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Learn Docker at Tecmint.com</title>
</head>
<body>

Learn Docker With Us

</body>
</html>


Stop Web Service

sudo docker stop tecmint-web

Remove Web Service

sudo docker rm tecmint-web
sudo docker image remove httpd:2.4



Referensi

Pranala Menarik