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"



Have Questions? Post them here!
Advertisements
Try Out Code2care Dev Tools:

Advertisements

Advertisements
Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.