3

I am using docker to build my dev enviroment, a very simple env where all i have is nginx and php-fpm.

So following docker docks I have created a docker-compose.yml:

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

php: image: php:7-fpm volumes: - ./code:/code

So what happens here i call nginx image and pgp-fpm image and link them.

I have also created a site.conf file:

server {
    index index.php;
    server_name php-docker.local;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /code;

    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;
   }
}

So here is all the server stuff.

with this set up i have sucesfully runned phpinfo(). When i However aded my app code i get an error complaning about pdo pdo_mysql extensions. So i did more research and found out i need a Dockerfile.

I created a docker file and and inside it added this commands:

FROM php:7
RUN docker-php-ext-install pdo pdo_mysql

Of course this does not work, I mean where does this install the extensions and how does my php-fpm supoose to see these extensions...?

2
  • Have you looked at the docs on the PHP repository in Dockerhub: hub.docker.com/_/php ? I've done this with the apache version, not fpm. With the apache version you create a Dockerfile and install any pre-reqs and RUN docker-php-ext-install pdo_mysql. I assume there is a similar method for FPM, see that readme and the corresponding github repo. Commented Jul 22, 2016 at 20:55
  • Have you run docker-compose build before running docker-compose up -d? Commented Aug 24, 2016 at 16:58

1 Answer 1

3

This Dockerfile help me:

FROM php:fpm
RUN apt-get update \
  && apt-get install -y --no-install-recommends libpq-dev \
  && docker-php-ext-install mysqli pdo_pgsql pdo_mysql

And this is part my docker-composer.yml

phpfpm:
  build: 
      context: ./php-fpm
      dockerfile: Dockerfile
  container_name: test-php-fpm
  links:
      - mysql
  volumes:
      - ./html:/usr/share/nginx/html
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.