Apache running on Alpine Linux.
4.4K
A Docker image for running Apache, based on Alpine Linux. This image belongs to a suite of images documented here.
This image features:
2.0.1, latest (Dockerfile)2.0.0 (Dockerfile)1.0.0 (Dockerfile)See VERSIONS.md for image contents.
To use this image include FROM smebberson/alpine-apache at the top of your Dockerfile, or simply docker run -p 80:80 -p 443:443 --name apache smebberson/alpine-apache.
Apache logs (access and error logs) aren't automatically streamed to stdout and stderr. To review the logs, you can do one of two things:
Run the following in another terminal window:
docker exec -i apache tail -f /var/log/apache2/access.log -f /var/log/apache2/error.log
or, in your Dockerfile symlink the Apache logs to stdout and stderr:
RUN ln -sf /dev/stdout /var/log/apache2/access.log && \
ln -sf /dev/stderr /var/log/apache2/error.log
This container comes setup as follows:
To alter the HTML content that Apache serves up, add the following to your Dockerfile:
ADD /path/to/content /var/www/localhost/
The /var/www/localhost/htdocs directory is the default document root, and index.html is set as the directory index (so index.html will get served if you don't ask for a file in the url), but these are easily changed by using your own httpd.conf (see below).
A basic Apache configuration is supplied with this image. However, it's easy to overwrite:
httpd.conf.Dockerfile, make sure your httpd.conf file is copied to /etc/apache/httpd.conf.Execute the command s6-svc -h /etc/services.d/apache to send a SIGHUP to Apache and have it reload configuration, launching new worker process(es) using this new configuration, while gracefully shutting down the old worker processes.
By default, if Apache crashes, the container will stop. This has been configured within root/etc/services.d/apache/finish. This is so the host machine can handle any issues, and automatically restart it (the docker way, docker run --autorestart).
If you don't want this to happen, simply replace the root/etc/services.d/apache/finish with a different file in your image. I like to ln -s /bin/true /root/etc/services.d/apache/finish in those instances in which you don't need a finish script and want to have the service restarted by s6.
If you need to, you can run a setup script before starting apache. During your Dockerfile build process, copy across a file to /etc/services.d/apache/run with the following (or customise it as required):
#!/usr/bin/env sh
if [ -e ./setup ]; then
./setup
fi
# start apache
exec /usr/sbin/apachectl -DFOREGROUND;
An example of using this image can be found in examples/user-apache.
Content type
Image
Digest
sha256:4f6932b10…
Size
7.4 MB
Last updated
over 10 years ago
docker pull smebberson/alpine-apache