This repository is contained Dockerfile and material for building images of PHP on official docker images.
FROM nmoeini/php:7.1-xenial
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
CMD [ "php", "./your-script.php" ]
Then, run the commands to build and run the Docker image:
$ docker build -t my-php-app .
$ docker run -it --rm --name my-running-app my-php-app
For running the FPM variants as an arbitrary user, the --user
flag to docker run
should be used (which can accept both a username/group in the container's /etc/passwd
file like --user daemon
or a specific UID/GID like --user 1000:1000
).
In many production environments, it is also recommended to (build and) enable the PHP core OPcache extension for performance. See the upstream OPcache documentation for more details.
In development environments, it is also recommended to (build and) enable the XDebug extension. See the Xdebug documentation for more details.
FROM nmoeini/php:7.2-xenial
COPY src/ /var/www/html/
Where src/
is the directory containing all your PHP code. Then, run the commands to build and run the Docker image:
$ docker build -t my-php-app .
$ docker run -d --name my-running-app my-php-app
$ docker run -d -p 80:80 --name my-apache-php-app -v "$PWD":/var/www/html nmoeini/php:7.4-bionic