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,

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

<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 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!

Top Hashtags: