- Notifications
You must be signed in to change notification settings - Fork6
DockerPHP: Dockerize any PHP project in under 5 minutes.
License
PHPExpertsInc/dockerize
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A utility for rapidly deployingDocker for PHP apps.
Watch the zero-dependency installation video:https://youtu.be/d8o9p2DimME
Installing on a legacy PHP 5.6 app in 2 minutes:https://youtu.be/xZxaJcsbrWU
This project has been tested against over 350,000 open-sourced Packagist packages (via the Bettergist Archiver project) and is compatible with 99.999% of them.
Includes:
- PHP 5.6, 7.0-7.4 + 8.0, 8.1, 8.2, 8.3, and 8.4.
- Nginx
- Redis v7.2
- PostgreSQL v16
- MariaDB v10.11
Current PHP versions:
- 5.6.40-81+ubuntu24.04.1+deb.sury.org+1
- 7.0.33-79+ubuntu24.04.1+deb.sury.org+1
- 7.1.33-67+ubuntu24.04.1+deb.sury.org+1
- 7.2.34-54+ubuntu24.04.1+deb.sury.org+1
- 7.3.33-24+ubuntu24.04.1+deb.sury.org+1
- 7.4.33
- 8.0.30
- 8.1.32
- 8.2.28
- 8.3.17
- 8.4.5
Thephpexperts/php:VESION-full
images contain every bundled PHP extension, and Redis.
- imap
- ldap
- pspell
- redis
- snmp
- xmlrpc
- Oracle ext-oci
Thephpexperts/php:VERSION-full
images contain everything in the full image plus drivers for Oracle (ext-oci8),
If you need an extension that is not available in thefull
build, please create an Issue at GitHub.
Watch theInstallation HOWTO video.
Here's another Zero Install demo including PHP 8.4 and the php-ci system for testing every version of PHP.
bash <(curl -s 'https://raw.githubusercontent.com/PHPExpertsInc/dockerize/v12.x/dockerize.sh')
Then edit credentials in .env.
docker compose up -d
# Ensure that vendor/bin is in your PATH and before /usr/bin.composer require --dev phpexperts/dockerizevendor/bin/php dockerize# Edit credentials in .env.docker-compose up -d
Don't forget to edit your docker-compose.yml!
In order to dockerize your existing PHP project, do the following:
Ensure that your profile PATH includes./vendor/bin
and that it takes priority over any other directory that may include a php executable:
PATH=./vendor/bin:$PATH
JetBrains generously grants this project a free Open-Source License to PhpStorm and all other JetBrains products as part of itsOpen Source License initiative.
- Super fast, completely automated installation. (Great for testing multiple versions on CIs)
- TheBIG difference betweenwww.phpdocker.io and Dockerize PHP is that Dockerize PHP provides all of the client utilities, where phpdocker.io provides NONE of them.
Out of the box, you have per-project binaries:
- php
- composer
- php-ci.sh
- mysql
- mysqldump
- psql
- pg_dump
- createdb
- dropdb
- redis
- redis-cli
With thephp-ci.sh shell script, you can easily test your app or library against every major version of PHP (currently 7.4-8.3):
In the project root directory, where your phpunit.xml is, or where you'd normally run phpunit:
vendor/bin/php-ci.sh
It will then automagically update composer and run the appropriate version of PHPUnit for all of the major PHP versionssupported by your project via the power of Docker.
- [2025-03-24 13:20:03 CDT] [bin/php] Complete fixed native PHP dispatching.
- [2025-03-23 00:33:11 CDT] Fixed a bug where the native PHP binary couldn't find files.
- [2024-12-21 13:32:23 CDT] Improved PHP 8.4 support.
- [2025-03-17 16:31:30 CDT] Built PHP 8.1.32, 8.2.28, 8.3.19, 8.4.5. HEAD -> v12.x
- [2025-03-13 17:25:06 CDT] [php-ci] Refactored a lot.
- [2025-03-12 18:32:13 CDT] Upgraded PHP 8.3.17 and 8.4.4.
- [2025-03-12 17:50:58 CDT] Renabled build support for PHP 5.6-7.3.
- [2025-03-12 17:45:01 CDT] [php-ci] Added support for PHPUnit v12.
- [2025-03-12 17:37:04 CDT] [php-ci] Added PHPUnit support for PHP 7.0 and 7.1.
- [2025-01-07 08:11:57 CST] Fixed a bug where native PHP detection via .env didn't work.
- [2024-12-13 02:18:41 CST] Added another YouTube demo.
- [2024-12-13 01:51:43 CST] Added PHP 8.4 support to php-ci.sh HEAD -> v12.x, origin/v12.x
- [2024-12-12 16:19:40 CST] Added support for PHP 8.4.
- [2024-12-12 23:55:18 CST] Majorly overhauled the dockerize installer.
- [2024-09-26 07:37:40 CDT] Add composer to the PHP 8.4 image. HEAD -> v11.0
- [2024-09-26 07:36:44 CDT] Fixed the PHP 8.4 entrypoint to use the standard entrypoint.
- [2024-09-13 03:48:00 CDT] Added support for PHP 8.4 beta5.
- [2024-09-12 05:30:37 CDT] [m] Updated the README.
- [2024-09-12 01:58:49 CDT] [m] Use the new ENV format in the Dockerfiles.
- [2024-09-12 01:44:09 CDT] Fixes for PHP 8.4 beta4 builds.
- [2024-09-09 12:55:33 CDT] [m] Prioritized the installation instructions in the README.md.
- [2024-09-07 18:55:07 CDT] [major] Upgraded to Ubuntu 24.04 Noble Numbat.
- [2024-09-07 18:55:45 CDT] Fixed a major reversion in web-debug by readding php-fpm.
- [2024-09-07 17:20:24 CDT] Added initial steps for creating a distroless PHP image. origin/v11.0
- [2024-09-07 19:00:42 CDT] Use a docker volume to store apt metadata.
- [2024-08-05 03:46:54 CDT] Added support for PHP 8.4 Alpha 4.
- [2024-08-05 04:33:33 CDT] Added a bash installation script to the composer package.
- [2024-06-29 10:13:12 CDT] [php-ci] Dynamically fetch and compute the supported PHP versions from the composer.json.
- [2024-06-29 10:20:39 CDT] [php-ci] Use phpunit's default config if there aren't version-specific xmls.
- [2024-06-29 10:20:48 CDT] [php-ci] Added support for PHPUnit v11.
- [2024-06-29 10:31:50 CDT] Create a Packagist alias to phpexperts/dockerise for SEO.
- [2024-06-26 00:57:05 CDT] Added my php-ci.sh script.
- [2024-05-24 07:40:15 CDT] Added a comprehensive zero-dependency Bash-via-curl installer.
- [2024-05-24 07:31:26 CDT] Added a mechanism for finding the first open HTTP port for nginx. master
- [2024-05-24 07:30:16 CDT] Redis removed v7.3 from docker; switched to v7.2.
- [2024-05-23 08:17:00 CDT] Upgraded to MariaDB 10.11, Redis 7.3, and Postgres 16.
- [2024-05-21 21:31:26 CDT] Configured it so that composer will run the install script.
- [2024-05-21 06:27:48 CDT] Fixes docker logs being truncated. origin/v9.
- [2024-01-16 03:15:49 CST] [major] Fixed a critical bug that prevented the dockerized php CLI from running in projects with a defined network.
- [2024-01-14 14:22:31 CST] Fixed the Docker installer.
- [2024-01-14 14:13:58 CST] Renamed the installer.
- [2024-01-14 14:12:02 CST] Switched the installer from wget to curl.
- [2024-01-14 07:06:07 CST] Added a zero-PHP-dependency Bash installer.
- [2024-01-14 07:04:47 CST] Added support for Linux ACLs in the base Linux image.
- [2024-01-14 07:03:35 CST] Fixed docker building bugs in base-oracle.
- [2024-01-14 06:40:56 CDT] [major] Fixed a critical bug that prevented the dockerized php CLI from running in new projects.
- [2024-01-13 23:04:49 CST] Added the Oracle ext-oci8 binaries, built against Ubuntu 22.04.
- [2024-01-13 22:51:39 CST] Added a docker build that contains the Oracle DB's ext-oci8 extension.
- [2024-01-13 22:50:16 CST] Added wget to the base PHP image.
- [2024-01-12 17:30:47 CST] Refactored IonCube builds so that the extension is only downloaded once.
- [2024-01-12 14:49:27 CST] Added a
full
docker build that contains every bundled PHP extension, and then some.
To control the containers, usedocker-compose
.
# Downloads the images, creates and launches the containers.docker-compose up -d# View the logsdocker-compose logs -ft# Stop the containersdocker-compose stop
That's it! You now have the latest LEPP (Linux, Nginx, PostgreSQL, PHP) stack orthe latest LEMP (Linux, Nginx, MariaDB, PHP) stack.
It is possible to control what UID the initial process (usually PHP) and/or PHP-FPM processes run as. Thebin/php
file already does this for the initial process.
This is important if you are mounting a volumes into the container, as the the UID of the initial process or PHP-FPM will likely need to match the volume to be able to read and/or write to it.
To set the UID for the PHP-FPM process, you should set thePHP_FPM_USER_ID
environmental variable on the container. e.g:
docker run -e PHP_FPM_USER_ID=1000 phpexperts/php:7 php-fpm5.6
PHP 5.6.40-81+ubuntu24.04.1+deb.sury.org+1 (cli) (built: Dec 24 2024 06:43:22) ( NTS )PHP 7.0.33-79+ubuntu24.04.1+deb.sury.org+1 (cli) (built: Dec 24 2024 06:43:22) ( NTS )PHP 7.1.33-67+ubuntu24.04.1+deb.sury.org+1 (cli) (built: Dec 24 2024 06:50:54) ( NTS )PHP 7.2.34-54+ubuntu24.04.1+deb.sury.org+1 (cli) (built: Dec 24 2024 06:58:15) ( NTS )PHP 7.3.33-24+ubuntu24.04.1+deb.sury.org+1 (cli) (built: Dec 24 2024 07:05:25) ( NTS )PHP 7.4.33 (cli) (built: Dec 24 2024 07:12:16) ( NTS )PHP 8.0.30 (cli) (built: Dec 24 2024 07:19:59) ( NTS )PHP 8.1.31 (cli) (built: Nov 21 2024 13:10:45) (NTS)PHP 8.2.27 (cli) (built: Dec 24 2024 06:29:37) (NTS)PHP 8.3.17 (cli) (built: Feb 15 2025 09:09:25) (NTS)PHP 8.4.4 (cli) (built: Feb 15 2025 08:59:26) (NTS)
Docker Hub:
PHP Experts, Inc., is my consultation company. It's a small company of a half dozenhighly skilled Full Stack PHP devs, including myself, whom I place at 1099 positions at other corporations. We fill bothlong-term positions and, for crazy devs like me, short-term. If you ever wanted to work on a different project/companyevery few months or even weeks, anywhere in the continental U.S., Europe, or South East Asia, it's fantastic.
Since 2015, I have set up branches in Las Vegas, Houston, the UK, Dublin, Costa Rica, Colombia, India, and the Philippines.If someone has a work auth in any of those places, we can place you almost anywhere you want. I travel 50% of the timeout of choice. All over the world.
About
DockerPHP: Dockerize any PHP project in under 5 minutes.