Public | Automated Build

Last pushed: 11 days ago
Short Description
Php base image
Full Description



FROM php:7-fpm
php -m

[PHP Modules]
bcmath, Core, ctype, curl, date, dom, fileinfo, filter, ftp, gd, gettext, hash, iconv, intl, json, libxml, mbstring, mcrypt, mongodb, mysqlnd, openssl, pcre, PDO, pdo_mysql, pdo_sqlite, Phar, posix, readline, Reflection, session, SimpleXML, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter, Zend OPcache, zip, zlib
[Zend Modules]
Zend OPcache

PHP version 7.1.8


  • works as Your local user (thanks to "UID mapping")
  • full i18n support (locale, intl, gettext)
  • able to run composer
  • Symfony & Yii frameworks compatibility test passed

UID mapping

Docker's php works as "www-data" user. After mapping Your local directory with project into docker's /opt, entrypoint load UID of /opt and replace "www-data" user's UID to new value. The result is that docker is working as Your local user (no "permission denied" errors etc)

using - quick HOWTO

1) Create docker-compose.yml in Your project

2) Add fpm rule as following:

    image: amsdard/php:7
    container_name: php7-fpm
        - /home/you/Projects/YourProject:/opt
    restart: always
  • set up /opt docker's location as main project directory

3) Create "Yakefile" file in Your base project's path

php: docker exec -it php7-fpm sudo -u www-data -g www-data php $CMD
app: yake php CMD="./app/console $CMD


docker-compose up -d
yake php /opt/check.php 
yake php -m

ImageMagick support

Create own Dockerfile using below schema:

FROM amsdard/php:7

RUN curl -fsSL '' -o ImageMagick.tar.gz && \
    tar xvzf ImageMagick.tar.gz && \
    cd ImageMagick-* && ./configure && yake && yake install && /sbin/ldconfig /usr/local/lib && \
    cd .. && rm -rf ImageMagick.tar.gz ImageMagick-* && \
    POLICY_XML_LOCATION="$(find /usr/local/etc/ -name 'policy.xml')" && \
    cp /files/imagemagick-policy.xml $POLICY_XML_LOCATION

RUN pecl install imagick && \
    docker-php-ext-enable imagick

advanced using - composer

To run composer using local composer.phar file and docker's PHP, You should use the following docker-compose.yml content:

    - ~/.docker-composer:/var/www/.composer
    - ~/.ssh:/var/www/.ssh
  • /var/www/ is home directory of "www-data" user. .composer is cache directory, and .ssh allows composer to use Your permissions.

And add to Yakefile (above the last line):

composer: yake php ./composer.phar --working-dir=/opt $CMD

then run:
yake composer install
yake composer require packagename
yake composer --help

advanced using - http server

Add to Your Yakefile (above the last line):

ip: docker inspect --format '{{ .NetworkSettings.IPAddress }}' $CMD

Then use docker's IP and port 9000 as FPM service.
BEWARE! Docker's IP is dynamic! so change e.g. after restart

Better way is to use nginx as docker with PHP connected as FPM service.

advanced using - nginx

Add to docker-compose.yml:

    image: nginx
    container_name: nginx
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
      - ./:/opt
      - php7

Create nginx.conf file:

server {
    listen          80;
    server_name     localhost;
    root            /opt;
    index           index.php;

    # here Your app rules

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;

        if (!-f $document_root$fastcgi_script_name) {
            return 404;

        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass php7-fpm:9000;
        fastcgi_index index.php;

Use fastcgi_pass php7-fpm:9000; PHP docker name here. Nginx as docker can use static other docker's name instead of dynamic IP.

Docker Pull Command
Source Repository

Comments (0)