This image adds common things that I usually need to the official php image, for both the apache and cli variants. See that repo for basic usage.
Images are built for PHP 8.0 through 8.5, each in an apache and a cli flavor, e.g. fsilva/php:8.5-apache or fsilva/php:8.5-cli. The cli variant does not ship the Apache config, vhost, custom php.ini or CMD — it's meant to be used for scripts, workers and Composer/CLI tooling.
PHP (via docker-php-ext-install)
PECL
Composer is installed at a pinned version (currently 2.10.2, see COMPOSER_VERSION in the Dockerfile). vendor/bin and $COMPOSER_HOME/vendor/bin are added to PATH, and $COMPOSER_HOME/cache is exposed as a volume so the download cache can be reused across containers.
When mounting a volume from the host to a container, the container sees the host's owner for the files, even if it doesn't exist in the container. This image has a feature that allows setting an environment variable (MAP_WWW_UID) to use a directory and get www-data to have the same uid and gid as the owner of that directory. It defaults to the current working dir, or set to no to disable.
This is useful for example if you're using some tooling in the container to generate files inside the host volume. If this is not used, the host will have files with uid=33 gid=33 or uid=0 gid=0, depending if you're using the www-data user or root.
Note that the container must be run as root, for the permission to change the www-data uid and gid.
Use gosu to run a command as www-data in order to use the mapped ownership.
$ # by default the current dir is used to change www-data's uid $ docker run -it --rm -v $PWD:/usr/src/app -w /usr/src/app fsilva/php gosu www-data id uid=1000(www-data) gid=1000(www-data) groups=1000(www-data)
$ # but you can specify another one $ docker run -it --rm -e MAP_WWW_UID=/data -v $PWD:/data fsilva/php gosu www-data id uid=1000(www-data) gid=1000(www-data) groups=1000(www-data)
$ # or disable it by setting MAP_WWW_UID=no $ docker run -it --rm -e MAP_WWW_UID=no -v $PWD:/data -w /data fsilva/php gosu www-data id uid=33(www-data) gid=33(www-data) groups=33(www-data)
The XDebug extension is installed but disabled by default. To enable, set the environment variable USE_XDEBUG=yes.
Opcache is enabled by default. To disable it, set the environment variable USE_OPCACHE=no.
The Apache vhost's DocumentRoot points to /var/www/app/$WEBROOT, which defaults to webroot. Set the environment variable WEBROOT to match your project's public folder name (e.g. public).
Content type
Image
Digest
sha256:ec5a55804…
Size
210.9 MB
Last updated
over 2 years ago
docker pull fsilva/php