42MB container image with basic PHP 5.6 installation and Composer,
based on AlpineLinux.
If you need to run PHP scripts inside containers,
but don't want the bulk of Ubuntu..
make sure to have required dependencies in composer.json
run your php scripts as:
docker run -it --rm -v $(pwd):/app anapsix/php --upgrade ./script_name.php
Make your own image based on this one like so (see [./example][https://github.com/anapsix/docker-php/tree/master/example]):
FROM anapsix/php
CMD ["./myscript.php"]
To install additional dependencies for your script/application, you can
place package names (one per line, comments and empty lines are ignored) into
./deps.apk. It will be checked for during the build and packages will be
installed via apk.
To install build-time only dependencies (system libraries, etc),
placepackage names into ./deps_build.apk. They will be removed after
compose install.
For list of available packages see http://pkgs.alpinelinux.org/packages.
For additional convenience, if ./deps.sh exists and is executable, it
will be run after ./deps.apk is processed. This should allow you to install
additional libraries not available in AlpineLinux APK repository or perform
any custom action (i.e. create users, clone a repo, install packages from
pecl/pear, etc).
Similarly to ./deps_build.apk, ./deps_build.sh can be used for custom
build-time pre-composer install steps. It is expected to be executable,
if present. After compose install it will be executed again with --cleanup
argument, which should allow for custom cleanup step.
Build it so:
docker build -t myapp .
and start it thus:
docker run -it --rm myapp
You could (re)build this image locally with:
docker build --no-cache -t anapsix/php https://github.com/anapsix/docker-php.git
docker pull anapsix/php:latest