1

I'm using docker-compose to setup a minimal nginx + php-fpm application but for some reason there is no php.ini file on the docker container (I know because phpinfo() says Loaded Configuration File: (none)).

Here's my docker-compose.yml file:

web:
  image: nginx
  ports:
    - "8080:80"
  volumes:
    - ./site.conf:/etc/nginx/conf.d/site.conf
  links:
    - php

php:
  image: php:5-fpm
  volumes:
    - .root:/var/www/html:ro
  command: bash -c "apt-get update && apt-get install -y php5-mysql && php-fpm"

site.conf is pretty straightforward as well:

server {
    index index.php;
    server_name local.myspicesage.com;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /var/www/html;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

And finally I have the most basic index.php possible:

<?php
echo phpinfo();

I really don't want to start from scratch if I don't have to. Is there supposed to be a php.ini file included with the php:5-fpm docker image? If not, is there a generic file I could use to start with?

  • 2
    Does the container you chose include a php.ini? What did the maintainer of the container tell you when you asked? – Michael Hampton Mar 23 '17 at 2:31
  • @Michael Hampton: Point taken. Let me ask and share back what I find. – skb Mar 23 '17 at 13:59
2

You need to add php.ini file:

  1. Run temporary php container

docker run -d --name php-tmp php:5-fpm

  1. Copy php archive

docker cp php-tmp:/usr/src/php.tar.xz .

  1. Extract php.ini-development or php.ini-production file to config dir. Example:

compose_root/php/php.ini-development

  1. Add volume with php.ini in php container

    volumes:

    • .root:/var/www/html:ro
    • ./php/php.ini-development:/usr/local/etc/php/php.ini
  • Or you could extract the files and use a dockerfile to build your container. – iwaseatenbyagrue Apr 3 '17 at 18:27

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.