Sign inSign up

garbetjie/php

By garbetjie

Updated 12 months ago

Image
1

50K+

garbetjie/php repository overview

PHP in Docker

An all-in-one PHP Docker image that comes preconfigured with a large range of extensions; and can be configured using environment variables. Supports PHP 7.2, 7.3, 7.4 & early support for 8.0.

See the list of available extensions to see whether the extension you need is included.

Source available at https://github.com/garbetjie/docker-php.

Table of contents

Using images

Docker images are available on Docker Hub, and can be pulled using the following command:

docker pull garbetjie/php:7.4-fpm

Additional images can be found on Docker Hub.

A note on PHP 8.0 images

PHP 8.0 is still in an early release phase. As such, not all extensions installed are available in the PHP 8.0 images, and there is no CLI version for PHP 8.0. As the missing extensions become compatible with PHP 8.0, they will be added.

Available variants

There are three variants that are available: cli, fpm and nginx. Each one is available for each PHP version. For example, these are the variants available:

  • garbetjie/php:7.X-cli Thread-safe version of PHP, with the parallel extension (but disabled) by default.

  • garbetjie/php:[7.x|8.0]-fpm PHP installed with PHP-FPM. All error logs are written to the container's stderr.

  • garbetjie/php:[7.x|8.0]-nginx PHP-FPM installed with the NGiNX webserver. This effectively turns the Docker container into a self-contained web server.

    Access logs are written to the container's stdout, and PHP-FPM logs are written to the container's stderr.

Configuration

There are a number of configuration options within PHP that are configurable through environment variables. Many of these are available across all variants, and some of them apply to specific image variants only.

Templating

Configuration is injected via shell templating. ESH is the templating engine that is used to build up configuration files. Any custom configuration files can also make use of ESH's syntax.

PHP

The environment variables below apply to all image variants, and are used to control the behaviour of PHP itself.

SectionNameINI equivalentDefault
PHP CoreDISPLAY_ERRORSdisplay_errors"Off"
ERROR_REPORTINGerror_reporting"E_ALL & ~E_DEPRECATED & ~E_STRICT"
HTML_ERRORShtml_errors"Off"
MAX_EXECUTION_TIMEmax_execution_time30
MAX_INPUT_TIMEmax_input_time30
MAX_REQUEST_SIZEpost_max_size"8M"
MEMORY_LIMITmemory_limit"64M"
OPCACHE_ENABLEDopcache.enabletrue
OPCACHE_CLI_ENABLEDopcache.enable_clifalse
OPCACHE_MAX_ACCELERATED_FILESopcache.max_accelerated_files10000
OPCACHE_REVALIDATE_FREQopcache.revalidate_freq2
OPCACHE_VALIDATE_TIMESTAMPSopcache.validate_timestampstrue
OPCACHE_SAVE_COMMENTSopcache.save_commentstrue
SESSION_COOKIE_NAMEsession.name"PHPSESSID"
SESSION_SAVE_HANDLERsession.save_handler"files"
SESSION_SAVE_PATHsession.save_path"/tmp/sessions"
TIMEZONEdate.timezone"Etc/UTC"
UPLOAD_MAX_FILESIZEupload_max_filesize"8M"
New Relic extensionNEWRELIC_ENABLEDN/A (Used to enable/disable the New Relic extension)false
NEWRELIC_APP_NAMEnewrelic.appname""
NEWRELIC_AUTORUM_ENABLEDnewrelic.browser_monitoring.auto_instrument0
NEWRELIC_DAEMON_LOGLEVELnewrelic.daemon.loglevel"error"
NEWRELIC_DAEMON_PORTnewrelic.daemon.port"@newrelic-daemon"
NEWRELIC_DAEMON_WAITN/A (Number of seconds to wait for New Relic daemon to connect to the reporting servers)3
NEWRELIC_HOST_DISPLAY_NAMEnewrelic.process_host.display_name""
NEWRELIC_LABELSnewrelic.labels""
NEWRELIC_LICENCEnewrelic.license""
NEWRELIC_LOGLEVELnewrelic.loglevel"info"
NEWRELIC_RECORD_SQLnewrelic.transaction_tracer.record_sql"obfuscated"
OpenCensus extensionOPENCENSUS_ENABLEDN/A (Used to enable/disable the OpenCensus extension)false
XDebug extensionXDEBUG_ENABLEDN/A (Used to enable/disable the XDebug extension)false
XDEBUG_IDE_KEYxdebug.idekey"IDEKEY"
XDEBUG_REMOTE_AUTOSTARTxdebug.remote_autostart0
XDEBUG_REMOTE_HOSTxdebug.remote_host"192.168.99.1"
XDEBUG_REMOTE_PORTxdebug.remote_port9000
FPM

The following variables apply to PHP-FPM.

NameFPM INI equivalentDefault
PMpm"static"
LISTENlisten"0.0.0.0:9000"
MAX_CHILDRENpm.max_children0
MIN_SPARE_SERVERSpm.min_spare_servers1
MAX_SPARE_SERVERSpm.max_spare_servers3
MAX_REQUESTSpm.max_requests10000
STATUS_PATHpm.status_path"/_/status"
TIMEOUTrequest_terminate_timeout60
NGiNX

The following variables apply to NGiNX. There is an overlap between these variables, and those that are configurable for PHP-FPM. In some instances, the NGiNX configuration overrides some of the defaults for PHP-FPM.

NameNGiNX config equivalentDefault
GZIP_TYPESgzip_types"application/ecmascript application/javascript application/json application/xhtml+xml application/xml text/css text/ecmascript text/javascript text/plain text/xml"
GZIP_PROXIEDgzip_types"any"
LISTENfastcgi_pass"/var/run/php-fpm.sock"
PORTlisten80
ROOTroot"/app/public"
STATUS_HOSTS_ALLOWEDallow"172.16.0.0/12 127.0.0.1"
STATUS_HOSTS_DENIEDdeny"all"
TIMEOUTfastcgi_read_timeout60

Known Issues

  • When using a version of PHP with thread safety enabled, you cannot use both the opencensus and parallel extensions at the same time. PHP will exit with a segmentation fault.

Available extensions

The following extensions are available:

[PHP Modules]
amqp  (7.x images only)
bcmath
bz2
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
igbinary
imap
intl
json
libxml
mbstring
memcached
msgpack
mysqlnd
newrelic  (7.x images only)
opencensus  (7.x images only)
openssl
parallel  (*-cli versions only)
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
tokenizer
xdebug
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

Changelog

  • 2020-07-05

    • Add support for PHP 8.0.
  • 2020-06-29

    • Update to PHP 7.4.7, 7.3.19.
    • Update all images to Alpine 3.12.
    • Add opcache configuration.
  • 2020-05-22

    • Bug fix: Incorrect ownership on /var/lib/nginx.
    • Update to PHP 7.4.6, 7.3.18, 7.2.31.
    • Update Composer to 1.10.6.
  • 2020-02-04

    • Add ability to configure gzip_proxied in NGiNX configuration.
  • 2020-01-31

    • Bump New Relic version to 9.6.1.256.
    • Add $NEWRELIC_LOGLEVEL configuration option.
    • Ensure $NEWRELIC_DAEMON_LOGLEVEL is respected.
    • Update Alpine versions to 3.11.
    • Update to PHP 7.2.27, 7.3.14, 7.4.2.
    • Increase $NEWRELIC_DAEMON_WAIT to 5 seconds.
    • Fix bug in which ZTS wasn't being calculated correctly. Only caused issues with -cli images.
  • 2020-01-08

    • Bug fix: Incorrect ownership on /var/tmp/nginx.
    • Bug fix: Create PHP session directory if files are being used.
    • Reduce interval between php-fpm checks to 0.25 seconds from 1 second.
  • 2019-12-19

    • Add NGiNX image.
    • Bump PHP versions (7.4.1, 7.3.13, 7.2.26).
    • Merge build commands into Dockerfile again -_-
    • Add missing templating to New Relic Daemon config.
    • Ensure NGiNX waits for FPM to start first.
  • 2019-12-17

    • Remove non-ZTS CLI image.
    • Disable parallel extension by default.
    • Move build commands into separate files.
  • 2019-12-14

    • Add WebP support to GD.
  • 2019-12-13

    • Add PHP 7.4 images.
    • Upgrade New Relic daemon for PHP 7.4 support.
    • Add $SESSION_COOKIE_NAME configuration, and fix $SESSSION_SAVE_* configuration not being used.
  • 2019-11-21

    • Add ability to enable/disable the opencensus extension. Set to disabled by default.
  • 2019-11-20

    • Add thread safe images (7.3-zts-cli and 7.2-zts-cli).
    • Add parallel extension in thread safe images.
    • Update PHP 7.3 to 7.3.11.
    • Update PHP 7.2 to 7.2.24.
  • 2019-11-14

    • Add $NEWRELIC_HOST_DISPLAY_NAME for configuring the display name of the server in the New Relic UI.
  • 2019-11-11

    • Add $NEWRELIC_DAEMON_LOGLEVEL for configuring the daemon logging level.
    • Update the starting of the Daemon process to implement a throwaway PHP process used to "prime" the daemon.
    • Change the default value of $NEWRELIC_DAEMON_WAIT from 5 to 3.
  • 2019-11-04

    • Update the README to include configuration of various SAPIs, as well as New Relic and XDebug extensions.
    • The New Relic daemon is now started manually (ie: outside of PHP). The container's command will now wait $NEWRELIC_DAEMON_WAIT seconds for the daemon to start before being executed.
    • Remove unused $XDEBUG_SERVER_NAME configuration variable.
    • Update composer version to 1.9.1.
    • Update New Relic agent to 9.2.0.247.

Tag summary

Content type

Image

Digest

sha256:1e0b8825a

Size

132.4 kB

Last updated

12 months ago

docker pull garbetjie/php:8.3-imagick