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.
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.
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.
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.
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.
The environment variables below apply to all image variants, and are used to control the behaviour of PHP itself.
| Section | Name | INI equivalent | Default |
|---|---|---|---|
| PHP Core | DISPLAY_ERRORS | display_errors | "Off" |
| ERROR_REPORTING | error_reporting | "E_ALL & ~E_DEPRECATED & ~E_STRICT" | |
| HTML_ERRORS | html_errors | "Off" | |
| MAX_EXECUTION_TIME | max_execution_time | 30 | |
| MAX_INPUT_TIME | max_input_time | 30 | |
| MAX_REQUEST_SIZE | post_max_size | "8M" | |
| MEMORY_LIMIT | memory_limit | "64M" | |
| OPCACHE_ENABLED | opcache.enable | true | |
| OPCACHE_CLI_ENABLED | opcache.enable_cli | false | |
| OPCACHE_MAX_ACCELERATED_FILES | opcache.max_accelerated_files | 10000 | |
| OPCACHE_REVALIDATE_FREQ | opcache.revalidate_freq | 2 | |
| OPCACHE_VALIDATE_TIMESTAMPS | opcache.validate_timestamps | true | |
| OPCACHE_SAVE_COMMENTS | opcache.save_comments | true | |
| SESSION_COOKIE_NAME | session.name | "PHPSESSID" | |
| SESSION_SAVE_HANDLER | session.save_handler | "files" | |
| SESSION_SAVE_PATH | session.save_path | "/tmp/sessions" | |
| TIMEZONE | date.timezone | "Etc/UTC" | |
| UPLOAD_MAX_FILESIZE | upload_max_filesize | "8M" | |
| New Relic extension | NEWRELIC_ENABLED | N/A (Used to enable/disable the New Relic extension) | false |
| NEWRELIC_APP_NAME | newrelic.appname | "" | |
| NEWRELIC_AUTORUM_ENABLED | newrelic.browser_monitoring.auto_instrument | 0 | |
| NEWRELIC_DAEMON_LOGLEVEL | newrelic.daemon.loglevel | "error" | |
| NEWRELIC_DAEMON_PORT | newrelic.daemon.port | "@newrelic-daemon" | |
| NEWRELIC_DAEMON_WAIT | N/A (Number of seconds to wait for New Relic daemon to connect to the reporting servers) | 3 | |
| NEWRELIC_HOST_DISPLAY_NAME | newrelic.process_host.display_name | "" | |
| NEWRELIC_LABELS | newrelic.labels | "" | |
| NEWRELIC_LICENCE | newrelic.license | "" | |
| NEWRELIC_LOGLEVEL | newrelic.loglevel | "info" | |
| NEWRELIC_RECORD_SQL | newrelic.transaction_tracer.record_sql | "obfuscated" | |
| OpenCensus extension | OPENCENSUS_ENABLED | N/A (Used to enable/disable the OpenCensus extension) | false |
| XDebug extension | XDEBUG_ENABLED | N/A (Used to enable/disable the XDebug extension) | false |
| XDEBUG_IDE_KEY | xdebug.idekey | "IDEKEY" | |
| XDEBUG_REMOTE_AUTOSTART | xdebug.remote_autostart | 0 | |
| XDEBUG_REMOTE_HOST | xdebug.remote_host | "192.168.99.1" | |
| XDEBUG_REMOTE_PORT | xdebug.remote_port | 9000 |
The following variables apply to PHP-FPM.
| Name | FPM INI equivalent | Default |
|---|---|---|
| PM | pm | "static" |
| LISTEN | listen | "0.0.0.0:9000" |
| MAX_CHILDREN | pm.max_children | 0 |
| MIN_SPARE_SERVERS | pm.min_spare_servers | 1 |
| MAX_SPARE_SERVERS | pm.max_spare_servers | 3 |
| MAX_REQUESTS | pm.max_requests | 10000 |
| STATUS_PATH | pm.status_path | "/_/status" |
| TIMEOUT | request_terminate_timeout | 60 |
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.
| Name | NGiNX config equivalent | Default |
|---|---|---|
| GZIP_TYPES | gzip_types | "application/ecmascript application/javascript application/json application/xhtml+xml application/xml text/css text/ecmascript text/javascript text/plain text/xml" |
| GZIP_PROXIED | gzip_types | "any" |
| LISTEN | fastcgi_pass | "/var/run/php-fpm.sock" |
| PORT | listen | 80 |
| ROOT | root | "/app/public" |
| STATUS_HOSTS_ALLOWED | allow | "172.16.0.0/12 127.0.0.1" |
| STATUS_HOSTS_DENIED | deny | "all" |
| TIMEOUT | fastcgi_read_timeout | 60 |
opencensus and parallel extensions
at the same time. PHP will exit with a segmentation fault.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
2020-07-05
2020-06-29
2020-05-22
/var/lib/nginx.2020-02-04
gzip_proxied in NGiNX configuration.2020-01-31
$NEWRELIC_LOGLEVEL configuration option.$NEWRELIC_DAEMON_LOGLEVEL is respected.$NEWRELIC_DAEMON_WAIT to 5 seconds.-cli images.2020-01-08
/var/tmp/nginx.2019-12-19
-_-2019-12-17
2019-12-14
2019-12-13
$SESSION_COOKIE_NAME configuration, and fix $SESSSION_SAVE_* configuration not being used.2019-11-21
opencensus extension. Set to disabled by default.2019-11-20
7.3-zts-cli and 7.2-zts-cli).parallel extension in thread safe images.2019-11-14
$NEWRELIC_HOST_DISPLAY_NAME for configuring the display name of the server in the New Relic UI.2019-11-11
$NEWRELIC_DAEMON_LOGLEVEL for configuring the daemon logging level.$NEWRELIC_DAEMON_WAIT from 5 to 3.2019-11-04
$NEWRELIC_DAEMON_WAIT
seconds for the daemon to start before being executed.$XDEBUG_SERVER_NAME configuration variable.Content type
Image
Digest
sha256:1e0b8825a…
Size
132.4 kB
Last updated
12 months ago
docker pull garbetjie/php:8.3-imagick