title: Adding PHP Extensions using Docker Compose
body: <p>I'm trying to setup a local development environment in docker that includes nginx and php. I started with <a href="http://geekyplatypus.com/dockerise-your-php-application-with-nginx-and-php7-fpm/" rel="noreferrer">this tutorial</a> and have a functioning server. My project requires that a couple PHP extensions be installed, but I'm having difficulty figuring out how to adapt this setup to include them.</p>
  
  <p>The documentation for the image says to put it in a dockerfile, which I have done. However, that gives me an error of:</p>
  
  <blockquote>
    <p>ERROR: The Compose file is invalid because:
    Service php has both an image and alternate Dockerfile. A service can either be built to image or use an existing image, not both.</p>
  </blockquote>
  
  <p>My <code>docker-compose.yml</code>:</p>
  
  <pre><code>web:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
    - ./code:/code
    - ./site.conf:/etc/nginx/conf.d/site.conf
    links:
      - php
  php:
    dockerfile: extensions
    image: php:7-fpm
    volumes:
      - ./code:/code
  </code></pre>
  
  <p>My <code>extensions</code> file</p>
  
  <pre><code>RUN docker-php-ext-install zip
  RUN docker-php-ext-install gd
  RUN docker-php-ext-enable zip
  RUN docker-php-ext-enable gd
  </code></pre>
  
  <p>Clearly I'm going about this wrong. Is there a way to install the extensions into this image, or do I need to create my own? I'm using Docker for Windows.</p>