title: docker-compose up Cannot create container for service php: failed to mount local volume
body: <p>I am trying to setup an existing project with docker. The project root directory contains a <code>docker-compose.yml</code> file. When I run <code>docker-compose up</code> I get the following message</p>
  
  <pre><code>Creating network "produkttests_default" with the default driver
  Creating volume "produkttests_nfsmount" with local driver
  Creating produkttests_db_1 ... done
  Creating produkttests_php_1 ... error
  
  ERROR: for produkttests_php_1  Cannot create container for service php: failed to mount local volume: mount ./:/Users/dennisfink/SANDBOX/produkttests:/var/lib/docker/volumes/produkttests_nfsmount/_data, data: addr=192.168.65.2,nolock,hard,nointr,nfsvers=3: connection refused
  
  ERROR: for php  Cannot create container for service php: failed to mount local volume: mount ./:/Users/dennisfink/SANDBOX/produkttests:/var/lib/docker/volumes/produkttests_nfsmount/_data, data: addr=192.168.65.2,nolock,hard,nointr,nfsvers=3: connection refused
  ERROR: Encountered errors while bringing up the project.
  </code></pre>
  
  <p>Now, I did some research on 'docker mount volume' and 'docker mount volume connection refused' but it didn't help me further. So, any ideas on why this error occurs?</p>
  
  <p><strong>./docker-compose.yml</strong></p>
  
  <pre><code>version: "3.1"
  services:
  
    web:
      image: nginx:latest
      ports:
        - "80:80"
        - "443:443"
      volumes:
        - nfsmount:/var/www/html
        - ./dockerconf/nginx/certs:/etc/nginx/certs
        - ./dockerconf/nginx/site.conf:/etc/nginx/conf.d/default.conf
      links:
        - php
  
    php:
      build: ./dockerconf/php
      links:
        - db
      volumes:
        - nfsmount:/var/www/html
  
    db:
      build: ./dockerconf/db
      ports:
        - "3306:3306"
      volumes:
         - ./dockerconf/db:/docker-entrypoint-initdb.d
         - ./dockerconf/db:/etc/mysql/conf.d
      environment:
        MYSQL_ROOT_PASSWORD: produkttester
        MYSQL_DATABASE: produkttester
        MYSQL_USER: produkttester
        MYSQL_PASSWORD: produkttester
  
  volumes:
    nfsmount:
      driver: local
      driver_opts:
        type: nfs
        o: addr=host.docker.internal,rw,nolock,hard,nointr,nfsvers=3
        device: "./:${PWD}"
  </code></pre>
  
  <p><strong>./dockerconf/php/Dockerfile</strong></p>
  
  <pre><code># See https://github.com/docker-library/php/blob/master/7.2/alpine3.8/fpm/Dockerfile
  FROM php:7.2-fpm-alpine
  ARG TIMEZONE
  
  RUN apk update \
      &amp;&amp; apk upgrade \
      &amp;&amp; apk add --no-cache \
      openssl \
      git \
      unzip \
      autoconf \
      file \
      g++ \
      gcc \
      dpkg-dev \
      dpkg \
      libc-dev \
      make \
      pkgconf \
      re2c \
      libpng \
      libjpeg-turbo \
      libpng-dev \
      jpeg-dev \
      libjpeg \
      libjpeg-turbo-dev \
      libssh2-dev
  
  RUN apk add --no-cache \
      --repository http://dl-3.alpinelinux.org/alpine/edge/community \
      gnu-libiconv
  
  ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php
  
  # Install Composer
  RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
  RUN composer --version
  
  # Set timezone
  RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime &amp;&amp; echo ${TIMEZONE} &gt; /etc/timezone
  RUN printf '[PHP]\ndate.timezone = "%s"\n', ${TIMEZONE} &gt; /usr/local/etc/php/conf.d/tzone.ini
  RUN "date"
  
  RUN echo "upload_max_filesize=20M" &gt; /usr/local/etc/php/conf.d/upload.ini
  
  RUN docker-php-ext-configure gd \
          --with-png-dir=/usr/lib/ \
          --with-jpeg-dir=/usr/lib/ \
          --with-gd
  
  # Type docker-php-ext-install to see available extensions
  RUN docker-php-ext-install gd \
      pdo \
      pdo_mysql \
      opcache \
      iconv
  
  RUN yes | pecl install ssh2-alpha \
      &amp;&amp; echo "extension=$(find /usr/local/lib/php/extensions/ -name ssh2.so)" &gt; /usr/local/etc/php/conf.d/ssh2.ini
  
  RUN yes | pecl install xdebug \
      &amp;&amp; docker-php-ext-enable xdebug \
      &amp;&amp; echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" &gt; /usr/local/etc/php/conf.d/xdebug.ini \
      &amp;&amp; echo "xdebug.idekey=XDEBUG" &gt;&gt; /usr/local/etc/php/conf.d/xdebug.ini \
      &amp;&amp; echo "xdebug.remote_enable=1" &gt;&gt; /usr/local/etc/php/conf.d/xdebug.ini \
      &amp;&amp; echo "xdebug.remote_mode=req" &gt;&gt; /usr/local/etc/php/conf.d/xdebug.ini \
      &amp;&amp; echo "xdebug.remote_port=9001" &gt;&gt; /usr/local/etc/php/conf.d/xdebug.ini \
      &amp;&amp; echo "xdebug.remote_autostart=off" &gt;&gt; /usr/local/etc/php/conf.d/xdebug.ini \
      &amp;&amp; echo "xdebug.remote_host=docker.for.mac.localhost" &gt;&gt; /usr/local/etc/php/conf.d/xdebug.ini \
      &amp;&amp; echo "xdebug.remote_connect_back=0" &gt;&gt; /usr/local/etc/php/conf.d/xdebug.ini
  
  RUN echo "realpath_cache_size = 4096k" &gt; /usr/local/etc/php/conf.d/realpath_cache.ini \
      &amp;&amp; echo "realpath_cache_ttl = 7200" &gt;&gt; /usr/local/etc/php/conf.d/realpath_cache.ini
  
  RUN set -xe
  RUN mkdir /appdata &amp;&amp; mkdir /appdata/cache &amp;&amp; mkdir /appdata/log &amp;&amp; chown -R www-data. /appdata
  
  WORKDIR /var/www/html
  </code></pre>
  
  <p><strong>EDIT: Additional information on docker volume</strong></p>
  
  <pre><code>$ docker volume inspect produkttests_nfsmount
  [
      {
          "CreatedAt": "2019-08-21T14:10:57Z",
          "Driver": "local",
          "Labels": {
              "com.docker.compose.project": "produkttests",
              "com.docker.compose.version": "1.24.1",
              "com.docker.compose.volume": "nfsmount"
          },
          "Mountpoint": "/var/lib/docker/volumes/produkttests_nfsmount/_data",
          "Name": "produkttests_nfsmount",
          "Options": {
              "device": "./:/Users/dennisfink/SANDBOX/produkttests",
              "o": "addr=host.docker.internal,rw,nolock,hard,nointr,nfsvers=3",
              "type": "nfs"
          },
          "Scope": "local"
      }
  ]
  </code></pre>