{"id":13424675,"url":"https://github.com/phpearth/docker-php","last_synced_at":"2025-03-15T18:35:44.253Z","repository":{"id":142700561,"uuid":"78793253","full_name":"phpearth/docker-php","owner":"phpearth","description":"🐳 Docker For PHP developers - Docker images with PHP, Nginx, OpenLiteSpeed, Apache, Lighttpd, and Alpine","archived":true,"fork":false,"pushed_at":"2020-05-06T17:26:04.000Z","size":581,"stargazers_count":262,"open_issues_count":24,"forks_count":79,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-10-26T23:55:39.591Z","etag":null,"topics":["alpine","apache","docker","docker-php","nginx","openlitespeed","php"],"latest_commit_sha":null,"homepage":"https://docs.php.earth/docker","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phpearth.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-12T22:37:19.000Z","updated_at":"2024-09-14T11:14:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"78b22fcb-e6bc-4121-ad92-745a5a883e77","html_url":"https://github.com/phpearth/docker-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpearth%2Fdocker-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpearth%2Fdocker-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpearth%2Fdocker-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpearth%2Fdocker-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpearth","download_url":"https://codeload.github.com/phpearth/docker-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243775913,"owners_count":20346285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alpine","apache","docker","docker-php","nginx","openlitespeed","php"],"created_at":"2024-07-31T00:00:57.643Z","updated_at":"2025-03-15T18:35:39.228Z","avatar_url":"https://github.com/phpearth.png","language":"Dockerfile","readme":"# Docker for PHP developers\n\n[![Build Status](https://img.shields.io/travis/phpearth/docker-php/master.svg?style=plastic)](https://travis-ci.org/phpearth/docker-php) [![Docker Automated build](https://img.shields.io/docker/automated/phpearth/php.svg?style=plastic)](https://hub.docker.com/r/phpearth/php/) [![MIT License](https://img.shields.io/github/license/phpearth/docker-php.svg?style=plastic \"MIT License\")](https://github.com/phpearth/docker-php/blob/master/LICENSE)\n\nCarefully crafted Docker images for PHP developers with PHP 7.3, PHP 7.2, PHP 7.1, PHP 7.0, Nginx, OpenLiteSpeed, Apache HTTP Server, and Lighttpd.\n\n![PHP.earth](https://cdn.rawgit.com/phpearth/logo/master/svg/indigo_300x300.svg \"PHP.earth\")\n\n* Fast and simple PHP extensions installation\n* Optional Composer installation\n* Optional PHPUnit installation\n* [runit](http://smarden.org/runit/) for running multiple services without overhead\n* Alpine base image with [PHP.earth PHP repositories](https://docs.php.earth/linux/alpine)\n* Optimized Docker image sizes\n* Multiple PHP versions\n\n## Documentation\n\nDocumentation with Docker and PHP recipes is available on [PHP.earth](https://docs.php.earth/docker).\n\n## Docker tags\n\nThe following list contains all current Docker tags and what is included in each.\n\n| System | Docker Tag | Features | Size |\n| ------ | ---------- | -------- | ---- |\n| **PHP 7.4.0alpha1**@Alpine 3.9.4 | [`7.4`](https://github.com/phpearth/docker-php/tree/master/docker/7.4.Dockerfile) | Small PHP CLI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.4.svg)](https://microbadger.com/images/phpearth/php:7.4 \"Image size\") |\n| | [`7.4-cli`](https://github.com/phpearth/docker-php/tree/master/docker/7.4-cli.Dockerfile) | PHP CLI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.4-cli.svg)](https://microbadger.com/images/phpearth/php:7.4-cli \"Image size\") |\n| | [`7.4-lighttpd`](https://github.com/phpearth/docker-php/tree/master/docker/7.4-lighttpd.Dockerfile) | Lighttpd 1.4.52 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.4-lighttpd.svg)](https://microbadger.com/images/phpearth/php:7.4-lighttpd \"Image size\") |\n| | [`7.4-litespeed`](https://github.com/phpearth/docker-php/tree/master/docker/7.4-litespeed.Dockerfile) | OpenLiteSpeed 1.5.0 RC3 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.4-litespeed.svg)](https://microbadger.com/images/phpearth/php:7.4-litespeed \"Image size\") |\n| | [`7.4-nginx`](https://github.com/phpearth/docker-php/tree/master/docker/7.4-nginx.Dockerfile) | Nginx 1.14.2, FPM | [![](https://images.microbadger.com/badges/image/phpearth/php:7.4-nginx.svg)](https://microbadger.com/images/phpearth/php:7.4-nginx \"Image size\") |\n| | [`7.4-apache`](https://github.com/phpearth/docker-php/tree/master/docker/7.4-apache.Dockerfile) | Apache 2.4.39 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.4-apache.svg)](https://microbadger.com/images/phpearth/php:7.4-apache \"Image size\") |\n| | [`7.4-cgi`](https://github.com/phpearth/docker-php/tree/master/docker/7.4-cgi.Dockerfile) | PHP CGI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.4-cgi.svg)](https://microbadger.com/images/phpearth/php:7.4-cgi \"Image size\") |\n| **PHP 7.3.4**@Alpine 3.9.3 | [`latest`, `7.3`](https://github.com/phpearth/docker-php/tree/master/docker/7.3.Dockerfile) | Small PHP CLI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.3.svg)](https://microbadger.com/images/phpearth/php:7.3 \"Image size\") |\n| | [`7.3-cli`](https://github.com/phpearth/docker-php/tree/master/docker/7.3-cli.Dockerfile) | PHP CLI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.3-cli.svg)](https://microbadger.com/images/phpearth/php:7.3-cli \"Image size\") |\n| | [`7.3-lighttpd`](https://github.com/phpearth/docker-php/tree/master/docker/7.3-lighttpd.Dockerfile) | Lighttpd 1.4.52 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.3-lighttpd.svg)](https://microbadger.com/images/phpearth/php:7.3-lighttpd \"Image size\") |\n| | [`7.3-litespeed`](https://github.com/phpearth/docker-php/tree/master/docker/7.3-litespeed.Dockerfile) | OpenLiteSpeed 1.5.0 RC3 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.3-litespeed.svg)](https://microbadger.com/images/phpearth/php:7.3-litespeed \"Image size\") |\n| | [`7.3-nginx`](https://github.com/phpearth/docker-php/tree/master/docker/7.3-nginx.Dockerfile) | Nginx 1.14.2, FPM | [![](https://images.microbadger.com/badges/image/phpearth/php:7.3-nginx.svg)](https://microbadger.com/images/phpearth/php:7.3-nginx \"Image size\") |\n| | [`7.3-apache`](https://github.com/phpearth/docker-php/tree/master/docker/7.3-apache.Dockerfile) | Apache 2.4.38 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.3-apache.svg)](https://microbadger.com/images/phpearth/php:7.3-apache \"Image size\") |\n| | [`7.3-cgi`](https://github.com/phpearth/docker-php/tree/master/docker/7.3-cgi.Dockerfile) | PHP CGI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.3-cgi.svg)](https://microbadger.com/images/phpearth/php:7.3-cgi \"Image size\") |\n| **PHP 7.2.17**@Alpine 3.9.3 | [`7.2`](https://github.com/phpearth/docker-php/tree/master/docker/7.2.Dockerfile) | Small PHP CLI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.2.svg)](https://microbadger.com/images/phpearth/php:7.2 \"Image size\") |\n| | [`7.2-cli`](https://github.com/phpearth/docker-php/tree/master/docker/7.2-cli.Dockerfile) | PHP CLI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.2-cli.svg)](https://microbadger.com/images/phpearth/php:7.2-cli \"Image size\") |\n| | [`7.2-lighttpd`](https://github.com/phpearth/docker-php/tree/master/docker/7.2-lighttpd.Dockerfile) | Lighttpd 1.4.52 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.2-lighttpd.svg)](https://microbadger.com/images/phpearth/php:7.2-lighttpd \"Image size\") |\n| | [`7.2-litespeed`](https://github.com/phpearth/docker-php/tree/master/docker/7.2-litespeed.Dockerfile) | OpenLiteSpeed 1.5.0 RC3 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.2-litespeed.svg)](https://microbadger.com/images/phpearth/php:7.2-litespeed \"Image size\") |\n| | [`7.2-nginx`](https://github.com/phpearth/docker-php/tree/master/docker/7.2-nginx.Dockerfile) | Nginx 1.14.2, FPM | [![](https://images.microbadger.com/badges/image/phpearth/php:7.2-nginx.svg)](https://microbadger.com/images/phpearth/php:7.2-nginx \"Image size\") |\n| | [`7.2-apache`](https://github.com/phpearth/docker-php/tree/master/docker/7.2-apache.Dockerfile) | Apache 2.4.38 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.2-apache.svg)](https://microbadger.com/images/phpearth/php:7.2-apache \"Image size\") |\n| | [`7.2-cgi`](https://github.com/phpearth/docker-php/tree/master/docker/7.2-cgi.Dockerfile) | PHP CGI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.2-cgi.svg)](https://microbadger.com/images/phpearth/php:7.2-cgi \"Image size\") |\n| **PHP 7.1.28**@Alpine 3.9.3 | [`7.1`](https://github.com/phpearth/docker-php/tree/master/docker/7.1.Dockerfile) | Small PHP CLI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.1.svg)](https://microbadger.com/images/phpearth/php:7.1 \"Image size\") |\n| | [`7.1-cli`](https://github.com/phpearth/docker-php/tree/master/docker/7.1-cli.Dockerfile) | PHP CLI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.1-cli.svg)](https://microbadger.com/images/phpearth/php:7.1-cli \"Image size\") |\n| | [`7.1-lighttpd`](https://github.com/phpearth/docker-php/tree/master/docker/7.1-lighttpd.Dockerfile) | Lighttpd 1.4.52 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.1-lighttpd.svg)](https://microbadger.com/images/phpearth/php:7.1-lighttpd \"Image size\") |\n| | [`7.1-litespeed`](https://github.com/phpearth/docker-php/tree/master/docker/7.1-litespeed.Dockerfile) | OpenLiteSpeed 1.5.0 RC3 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.1-litespeed.svg)](https://microbadger.com/images/phpearth/php:7.1-litespeed \"Image size\") |\n| | [`7.1-nginx`](https://github.com/phpearth/docker-php/tree/master/docker/7.1-nginx.Dockerfile) | Nginx 1.14.2, FPM | [![](https://images.microbadger.com/badges/image/phpearth/php:7.1-nginx.svg)](https://microbadger.com/images/phpearth/php:7.1-nginx \"Image size\") |\n| | [`7.1-apache`](https://github.com/phpearth/docker-php/tree/master/docker/7.1-apache.Dockerfile) | Apache 2.4.38 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.1-apache.svg)](https://microbadger.com/images/phpearth/php:7.1-apache \"Image size\") |\n| | [`7.1-cgi`](https://github.com/phpearth/docker-php/tree/master/docker/7.1-cgi.Dockerfile) | PHP CGI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.1-cgi.svg)](https://microbadger.com/images/phpearth/php:7.1-cgi \"Image size\") |\n| **PHP 7.0.33**@Alpine 3.7.3 | [`7.0`](https://github.com/phpearth/docker-php/tree/master/docker/7.0.Dockerfile) | Small PHP CLI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.0.svg)](https://microbadger.com/images/phpearth/php:7.0 \"Image size\") |\n| | [`7.0-cli`](https://github.com/phpearth/docker-php/tree/master/docker/7.0-cli.Dockerfile) | PHP CLI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.0-cli.svg)](https://microbadger.com/images/phpearth/php:7.0-cli \"Image size\") |\n| | [`7.0-lighttpd`](https://github.com/phpearth/docker-php/tree/master/docker/7.0-lighttpd.Dockerfile) | Lighttpd 1.4.48 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.0-lighttpd.svg)](https://microbadger.com/images/phpearth/php:7.0-lighttpd \"Image size\") |\n| | [`7.0-litespeed`](https://github.com/phpearth/docker-php/tree/master/docker/7.0-litespeed.Dockerfile) | OpenLiteSpeed 1.5.0 RC3 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.0-litespeed.svg)](https://microbadger.com/images/phpearth/php:7.0-litespeed \"Image size\") |\n| | [`7.0-nginx`](https://github.com/phpearth/docker-php/tree/master/docker/7.0-nginx.Dockerfile) | Nginx 1.12.2, FPM | [![](https://images.microbadger.com/badges/image/phpearth/php:7.0-nginx.svg)](https://microbadger.com/images/phpearth/php:7.0-nginx \"Image size\") |\n| | [`7.0-apache`](https://github.com/phpearth/docker-php/tree/master/docker/7.0-apache.Dockerfile) | Apache 2.4.38 | [![](https://images.microbadger.com/badges/image/phpearth/php:7.0-apache.svg)](https://microbadger.com/images/phpearth/php:7.0-apache \"Image size\") |\n| | [`7.0-cgi`](https://github.com/phpearth/docker-php/tree/master/docker/7.0-cgi.Dockerfile) | PHP CGI | [![](https://images.microbadger.com/badges/image/phpearth/php:7.0-cgi.svg)](https://microbadger.com/images/phpearth/php:7.0-cgi \"Image size\") |\n\nTags follow PHP release cycle and [PHP supported versions timeline](http://php.net/supported-versions.php).\n\n| PHP     | Active Support Until | Security Support Until | Info |\n| ------- | -------------------- | ---------------------- | ---- |\n| **7.4** | TBD                  | TBD                    | Development 7.4 branch for testing |\n| **7.3** | TBD                  | TBD                    | Current recommended branch for production |\n| **7.2** | 2019-11-30           | 2020-11-20             | Previous stable branch |\n| **7.1** | 2018-12-01           | 2019-12-01             | Previous branch for legacy projects |\n| **7.0** | 2017-12-03           | 2018-12-03             | Previous branch for legacy projects, not supported anymore |\n\n## Quick usage\n\n### Nginx\n\n`Dockerfile` for running Nginx HTTP server with PHP FPM:\n\n```Dockerfile\nFROM phpearth/php:7.3-nginx\n```\n\nBuild Docker image and run Docker container:\n\n```bash\ndocker build -t custom-php .\ndocker run --name custom-php-container -p 80:80 -d custom-php\n```\n\n### PHP CLI\n\nTo run a CLI PHP script:\n\n```bash\ndocker run -it --rm -v `pwd`:/usr/src/myapp -w /usr/src/myapp phpearth/php php script.php\n```\n\n### Composer\n\nTo install Composer:\n\n```Dockerfile\nFROM phpearth/php:7.3-nginx\n\nRUN apk add --no-cache composer\n```\n\n### PHPUnit\n\nTo install PHPUnit:\n\n```Dockerfile\nFROM phpearth/php:7.3-nginx\n\nRUN apk add --no-cache phpunit\n```\n\n### OpenLiteSpeed\n\nTo run OpenLiteSpeed web server:\n\n```Dockerfile\nFROM phpearth/php:7.3-litespeed\n```\n\n### Lighttpd\n\nTo run Lighttpd web server:\n\n```Dockerfile\nFROM phpearth/php:7.3-lighttpd\n```\n\n### PHP extensions\n\nTo install additional PHP extensions, you can use packages from the [PHP.earth Alpine repository](https://docs.php.earth/linux/alpine):\n\n```Dockerfile\nFROM phpearth/php:7.3-nginx\n\nRUN apk add --no-cache php7.3-sodium php7.3-intl php7.3-pdo_mysql\n```\n\nor install them with `pecl`:\n\n```bash\napk add --no-cache php7.3-dev gcc g++\npecl install {extension-name}\n```\n\n### PHP ini settings\n\nTo configure extra [php.ini](https://www.php.net/manual/en/ini.php): settings,\ncreate application specific `php.ini` and copy the file into docker image:\n\n\n```ini\n# php.ini\nmemory_limit = 512M\n```\n\n```Dockerfile\nFROM phpearth/php:7.3-nginx\n\nCOPY php.ini $PHP_INI_DIR/conf.d/my-app.ini\n```\n\n#### Missing extension?\n\nIn case you'd need an additional extension in the PHP.earth repository, [open an issue](https://github.com/phpearth/docker-php/issues).\n\n### Docker Stack\n\nDocker Stack is way of orchestration of Docker services and simplifies running multiple services of your application. In this example we'll run an Nginx web server with PHP 7.3 FPM with `docker-compose.yml` file. In a new project directory create a `Dockerfile`:\n\n```Dockerfile\nFROM phpearth/php:7.3-nginx\n```\n\nThe `docker-compose.yml` file:\n\n```yml\nversion: '3.3'\n\nservices:\n  app:\n    image: my-dev-image\n    volumes:\n      - .:/var/www/html\n    ports:\n      - mode: host\n        target: 80\n        published: 80\n```\n\nThe `index.php` file:\n\n```php\n\u003c?php\n\nphpinfo();\n```\n\nFinally we run:\n\n```bash\n# Initialize a new Swarm for development\ndocker swarm init\n# Build above image\ndocker build -t my-dev-image -f Dockerfile .\n# Deploy the above stack up and running\ndocker stack deploy -c docker-compose.yaml mystack\n```\n\nAnd there should be `phpinfo()` output visible on `http://localhost`. Make sure there isn't any other service listening on port 80 before running above command.\n\n### PHP 7.0, 7.1, PHP 7.2\n\nTo use older versions PHP 7.0, 7.1, or 7.2 use Docker images with `7.0`, `7.1`, or `7.2`:\n\n```Dockerfile\nFROM phpearth/php:7.2-nginx\n\nRUN apk add --no-cache composer\n```\n\n## PHP.earth Alpine repository\n\nThese Docker images include the latest PHP versions and packages for Alpine Linux via the 3rd party [PHP.earth Alpine repository](https://docs.php.earth/linux/alpine).\n\n```Dockerfile\nFROM alpine:3.8\n\nADD https://repos.php.earth/alpine/phpearth.rsa.pub /etc/apk/keys/phpearth.rsa.pub\nRUN echo \"https://repos.php.earth/alpine\" \u003e\u003e /etc/apk/repositories \\\n    \u0026\u0026 apk add --no-cache php7.3\n```\n\nPHP.earth Alpine packages are prefixed with `php7.3`, `php7.2`, `php7.1`, and `php7.0`.\n\n## Building Images\n\nImages are automatically build on [Docker Hub](https://hub.docker.com/r/phpearth/php/).\n\nDocker Cloud and therefore Docker Hub also provides\n[overriding and customization](https://docs.docker.com/docker-cloud/builds/advanced/)\nof various commands when building images automatically.\n\nThere are some hooks defined in the `docker/hooks` folder:\n\n* `hooks/build` - executed when building image\n* `hooks/post_push` - executed after building image, used to push additional tags\n  to Docker Hub.\n\n### Labels\n\n[Labels](https://docs.docker.com/engine/userguide/labels-custom-metadata/) are\nneat way to expose additional metadata about particular Docker object. We use\n[Label Schema](http://label-schema.org/) when defining image labels:\n\n* `build-date` - Date and time of the build. Defined as\n  `org.label-schema.build-date=$BUILD_DATE`, where `$BUILD_DATE` is set dynamically\n  via above `hooks/build` script\n* `vcs-url` - Repository location on GitHub. Defined as\n  `org.label-schema.vcs-url=\"https://github.com/phpearth/docker-php.git\"`\n* `vcs-ref` - Reference to commit in Git repository\n* `schema-version` - Version of the Label Schema in use.\n* `vendor` - Vendor name of the image creators.\n* `name`\n* `description`\n* `url`\n\n## License and contributing\n\n[Contributions](https://github.com/phpearth/docker-php/blob/master/.github/CONTRIBUTING.md) are most welcome. This repository is released under the [MIT license](https://github.com/phpearth/docker-php/blob/master/LICENSE).\n","funding_links":[],"categories":["Development","Dockerfile"],"sub_categories":["Programming"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpearth%2Fdocker-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpearth%2Fdocker-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpearth%2Fdocker-php/lists"}