Public Repository

Last pushed: 10 months ago
Short Description
Alpine Linux v3.4 with Apache and PHP installed at /usr/sbin/httpd. No SSL/TLS support. 7MB.
Full Description


A handy basic image comprising of;

  • Alpine Linux v3.4. A security-oriented, lightweight Linux distribution based on musl libc and BusyBox.
  • Apache v2.4.23 listening on port 80, serving a basic page at /index.html.
    • Compression is enabled using mod_deflate
    • For testing purposes mod_alias is configured to redirect /30180 to http://localhost/index.html (using a 301) & /30280 to http://localhost/index.html (using a 302)
    • In case you are also using my HAProxy image (which listens on port 8080) in front of this web server, redirects are also available from /3018080 to http://localhost:8080/index.html (using a 301) & and /3028080 to http://localhost:8080/index.html (using a 302)
    • For additional testing purposes, four cookies are included with all standard responses, one without attributes, one with the HttpOnly attribute, one with the HttpOnly and Secure attributes and finally one with the HttpOnly, Secure and SameSite attributes
  • PHP v5.6.25, with a basic version display script available via /index.php. This page also display the server's host name which is handy when testing load balancing across multiple servers and hosts.

This image is around 33% the size of the most popular one available on Docker hub today.

If you're looking for an image which supports SSL/TLS use this one.

I've also created a HAProxy image with this server (localhost:80) configured as a backend here.


I'd expect you use this image as a simple web server that can be quickly modified, if required, via volume mounts.

To replace the Apache configuration file with your own, mount a volume to /etc/apache2/ which contains your own httpd.conf. Alternatively mount just the file.

A default php.ini file is relied upon. To replace it with your own, mount a volume to /etc/php/ which contains your own file. Alternatively mount just the file.

Equally you can do the same for the served index.html and index.php files which are both located at /var/www/localhost/htdocs/ within the container.

Include files can be used to provide further configuration if you mount them via the: /etc/apache2/conf.d/ directory.

The Init/Entrypoint Script

Apache is started via the /usr/bin/ script, which runs as PID1;

  • By default six httpd threads are started. These can be displayed using the ps -e command
  • The /etc/apache2/httpd.conf script is displayed by the scipt on start-up via STDOUT, as is the Apache version
  • The KILL signal, as sent by the docker stop command by default, is 'trapped' by the script and will stop the container
  • Failure, or a manual KILL of the httpd process(es) will result in the container stopping/failing - which allows for container automation and orchestration systems to re-launch or re-start the container

On the downside, you can't restart the process(es).


Use this command to pull the image manually and before runtime:

sudo docker pull itsthenetwork/alpine-apache:latest


This command will start the container non-interactively, using host networking mode; thus port 80 will be used on the localhost (note there is no need for privileged mode):

sudo docker run -d --net=host --name apache itsthenetwork/alpine-apache:latest

If you'd rather use the default bridge mode networking and map a port from your host to the container, use something like this:

sudo docker run -d -p 5000:80 --name apache itsthenetwork/alpine-apache:latest


As long as you are using host mode networking as specified above, you can confirm the container and Apache within it is listening on port 80 using this command:

ss -ltn

Alternatively on old/bare/BusyBox systems use:

netstat -ltn


You can 'attach' to your container like so (assuming you used the run command and --name parameter above):

docker exec -it apache sh

You can view the container's logs like so (assuming you used the run command and --name parameter above):

sudo docker logs apache


Stop and remove the container like so (assuming you used the run command and --name parameter above):

docker stop apache; docker rm apache

To save performing the remove step add --rm=true to your docker run command and remove the -d parameter. This will result in:

sudo docker run --rm=true --net=host --name apache itsthenetwork/alpine-apache:latest

Additional Packages

If you wanted to install additional packages and build your own image based upon this one you'd start your Dockerfile like this:

FROM itsthenetwork/alpine-apache:latest

RUN apk -add U -v package_name package_name


Base Dockerfile

The Dockerfile used to create this image was:

FROM alpine:3.4
MAINTAINER Steven Iveson <>

RUN echo > /etc/apk/repositories && \
    echo >> /etc/apk/repositories && \
    echo >> /etc/apk/repositories && \
    apk add -U -v apache2 php-apache2 && mkdir /run/apache2/ && rm -rf /var/cache/apk/* /tmp/*

COPY httpd.conf /etc/apache2/httpd.conf
COPY index.html /var/www/localhost/htdocs/index.html
COPY index.php /var/www/localhost/htdocs/index.php
COPY robots.txt /var/www/localhost/htdocs/robots.txt
COPY favicon.ico /var/www/localhost/htdocs/favicon.ico
COPY /usr/bin/

RUN ln -sf /dev/stdout /var/log/apache2/access.log && \
     ln -sf /dev/stderr /var/log/apache2/error.log && \
     mkdir -p /run/apache2/ && \
     chown apache:apache /run/apache2/ && \
     chmod 777 /run/apache2/ && chmod +x /usr/bin/

ENTRYPOINT ["/usr/bin/"]
Docker Pull Command

Comments (0)