Carefully crafted Docker Squash to reduce the size of the final Docker image for PHP + Apache with PHP 7.3, PHP 7.2, PHP 7.1, PHP 7.0, Apache.
The following list contains all current Docker tags and what is included in each.
| System | Docker Tag | Features | Size |
|---|---|---|---|
| PHP 7.0.33@Alpine 3.7.3 | 7.0-apache | Apache 2.4.38 | |
| PHP 7.1.28@Alpine 3.9.3 | 7.1-apache | Apache 2.4.38 | |
| PHP 7.2.17@Alpine 3.9.3 | 7.2-apache | Apache 2.4.38 | |
| PHP 7.3.4@Alpine 3.9.3 | 7.3-apache | Apache 2.4.38 | |
| PHP 7.4.0alpha1@Alpine 3.9.4 | 7.4-apache | Apache 2.4.39 |
Dockerfile for running Nginx HTTP server with PHP FPM:
FROM pull dockerstacks/apache2_php:v{PHP Version}
### Composer
To install Composer:
```Dockerfile
FROM dockerstacks/apache2_php:v{PHP Version}
RUN apk add --no-cache composer
To install PHPUnit:
FROM dockerstacks/apache2_php:v{PHP Version}
RUN apk add --no-cache phpunit
FROM dockerstacks/apache2_php:v{PHP Version}
RUN apk add --no-cache php7.3-sodium php7.3-intl php7.3-pdo_mysql
or install them with pecl:
apk add --no-cache php7.3-dev gcc g++
pecl install {extension-name}
create application specific php.ini and copy the file into docker image:
# php.ini
memory_limit = 512M
FROM dockerstacks/apache2_php:v{PHP Version}
COPY php.ini $PHP_INI_DIR/conf.d/my-app.ini
Docker 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:
FROM dockerstacks/apache2_php:v{PHP Version}
The docker-compose.yml file:
version: '3'
services:
app:
image: dockerstacks/apache2_php:v{PHP Version}
volumes:
- .:/var/www/localhost/htdocs
ports:
- mode: host
target: 80
published: 80
The index.php file:
<?php
phpinfo();
And 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.
To use older versions PHP 7.0, 7.1, or 7.2 use Docker images with 7.0, 7.1, or 7.2:
FROM dockerstacks/apache2_php:v{PHP Version}
RUN apk add --no-cache composer
Content type
Image
Digest
Size
14.7 MB
Last updated
almost 6 years ago
docker pull deckapp/apache_php