Php: Apache image backed by Alpine

Created on 13 Jul 2016  路  12Comments  路  Source: docker-library/php

Would it be worth the effort to swap over the apache tag to start from the Alpine base image? I'm currently building an image and bundling composer and ending up around 350MB. Was curious to find out if there was a technical reason for it not happening or if it was just a lack of time.

Most helpful comment

I'm working on a build for Alpine (currently 3.8 but will support 3.9) with Apache with @sudomabider. Its taking a little longer as we are working on it outside of normal working hours but I hope to be able to raise a PR shortly for the team to consider merging:

https://github.com/mrtimp/php/pull/1

All 12 comments

Currently I think it is because the apache part is taken directly from Debian and so it has things that users are used to existing in their php/apache world, which would not necessarily be the case in an alpine version. Also, since the Alpine variants exist mostly for size concerned users, then they would be better served with fpm and something like nginx in front of it.

I too would be interested in this. I'm running several WordPress sites on php:7.0-apache and they are weighing in at about 440-460 MB.

Alternatively if anyone has any suggestions on how to reduce the size of php:7.0-apache that would be welcome as well.

@asmaloney as alternative you could configure two containers https://hub.docker.com/_/nginx/ 1.11-alpine (19 mb) and https://hub.docker.com/_/php/ 7.0-fpm-alpine (31 MB).
as result it would be 50 mb instead of 164mb for base image!

@ihor-sviziev That's a good idea. My sites are (slightly) dependent on apache though and what I have right now is working (just large) so for my use-case it's probably not worth disrupting things that much.

Thanks for the suggestion!

@asmaloney here is apache container with in alpine linux: https://hub.docker.com/_/httpd/. I think we can use some parts of it to prepare apache+php container.

Also voting for alpine based image. Currently building it myself from Alpine's packages, as apache+mod_php is slightly more convenient to use in docker environment then php-fpm. Image size results around 120 MB (41 MB compressed). Also love Alpine's busybox.

+1 for alpine image.

@yosifkit @ihor-sviziev you can't use php-fpm + nginx in swarm mode, without separate step of copy and deploy all statics.

I create Docker image PHP + Apache https://hub.docker.com/r/vlastv/php/tags/. You can create PR if you known as optimize https://github.com/vlastv/docker-php.

Given the complexity involved in duplicating Debian's Apache configuration and usage for Alpine, I don't think this is going to be solved any time soon.

The best advice I can give is to either use the Debian version (since the size difference is not _that_ dramatic, given today's normal storage and bandwidth availability), or to use FPM (which is also much more in the spirit of Alpine's minimalism). Thanks! :heart:

I beg you to reconsider adding Apache Alpine variant. Many people use Alpine not because of its size (although it's a nice benefit), but because it's simple and secure. The problem with FPM images is that I'm looking for self-contained solutions and I don't wanna write custom Nginx configurations for each application I run, mainly because it's just rewriting .htaccess files distributed with applications. For now, I'll probably use CLI Alpine variant and install Apache myself, but having Apache Alpine variant would make my life a bit easier.

I'm working on a build for Alpine (currently 3.8 but will support 3.9) with Apache with @sudomabider. Its taking a little longer as we are working on it outside of normal working hours but I hope to be able to raise a PR shortly for the team to consider merging:

https://github.com/mrtimp/php/pull/1

This would be needed for a single-container alpine version of wikimedia/mediawiki-docker.
See: https://phabricator.wikimedia.org/T241323

Was this page helpful?
0 / 5 - 0 ratings