Alpine Linux v3.8.1 with Apache v2.4 and PHP v7 installed at /usr/sbin/httpd. No TLS support. 6MB.
3.3K
A handy basic image comprising of;
For previous tag v9:
For previous tag v8:
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.
Apache is started via the /usr/bin/httpd.sh script, which runs as PID1;
ps -e commanddocker stop command by default, is 'trapped' by the script and will stop the containerOn 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
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
...
The Dockerfile used to create this image is available at the root of the file system, here it is anyway:
FROM alpine:latest
LABEL maintainer "Steven Iveson <[email protected]>"
COPY Dockerfile /Dockerfile
RUN apk add -U -v apache2 php-apache2 && mkdir /run/apache2/ && \
rm -rf /var/cache/apk/* /tmp/* /sbin/halt /sbin/poweroff /sbin/reboot
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 httpd.sh /usr/bin/httpd.sh
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/httpd.sh
ENTRYPOINT ["/usr/bin/httpd.sh"]
Content type
Image
Digest
Size
6.1 MB
Last updated
almost 8 years ago
docker pull itsthenetwork/alpine-apache