PHP Dockerfiles with additional libraries (mainly for our needs)
Move to the folder containing the desired Dockerfile.
Build the image
docker build -t <dockertag> .
Create a shell script called php<version>.sh
with this content :
#!/bin/bash
docker run --rm --interactive --tty \
--workdir /usr/src/myapp \
--volume $PWD:/usr/src/myapp \
--user $(id -u):$(id -g) \
<dockertag> php "$@"
All images are available at : https://hub.docker.com/r/ihneo/php
You can pull all images with the command :
docker pull ihneo/php:<dockertag>
7.1-cli-alpine
7.2-cli-alpine
7.3-cli-alpine
7.4-cli-alpine
8.0-cli-alpine
8.1-cli-alpine
8.2-cli-alpine
8.3-cli-alpine
,latest
7.1-fpm-alpine
7.2-fpm-alpine
7.3-fpm-alpine
7.4-fpm-alpine
8.0-fpm-alpine
8.1-fpm-alpine
8.2-fpm-alpine
8.3-fpm-alpine
#!/bin/bash
docker run --rm --interactive --tty \
--workdir /usr/src/myapp \
--volume $PWD:/usr/src/myapp \
--user $(id -u):$(id -g) \
ihneo/php:<dockertag> php "$@"
Composer is also available in all images
To use composer in version 1, command is composer
To use composer in version 2, command is composer2
An example to use the docker image as a composer binary :
#!/bin/bash
docker run --rm --interactive --tty \
--env COMPOSER_HOME=/tmp/composer/config \
--env COMPOSER_CACHE_DIR=/tmp/composer/cache \
--workdir /app \
--volume $PWD:/app \
--volume ${COMPOSER_HOME:-$HOME/.config/composer}:/tmp/composer/config \
--volume ${COMPOSER_CACHE_DIR:-$HOME/.cache/composer}:/tmp/composer/cache \
--user $(id -u):$(id -g) \
ihneo/php:<dockertag> composer "$@"