Docker Alpine Linux and Apache2 Example


Alpine Linux running Apache2 Example

In this article, we will take a look at how to run an Apache2 HTTP Server on Alpine Linux and host a simple HTML page,



Dockerfile:
FROM alpine:latest
RUN apk add apache2
COPY index.html /var/www/localhost/htdocs
CMD ["sh"]


index.html
<html><body><h1>Hello from Alpine Linux running Apache2</h2></body></html>


Build the Dockerfile
% docker build -t alpine-apache-http .
[+] Building 0.1s (10/10) FINISHED  


Running the Dockerfile
docker run -it -p 8080:80 alpine-apache-http sh
# /usr/sbin/httpd

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, 
using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
/ # cd /var/www/localhost/htdocs

In order to start the apache2 server on Alpine Linux on Docker run the command "/usr/sbin/httpd"

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap