Docker Community Forums

Share and learn in the Docker community.

Failed to mount local volume

Hi all,

This is my very first time using docker (I know. I missed a lot).
Anyway, I encountered this issue and wonder if anyone experienced (and hopefully solved) this?

Thanks!

Your question says “local volume” but the image seems to indicate you’re trying to connect to some NFS share on some IP address?

Is it a folder on your local machine (then you probably don’t need to use NFS)? If it’s indeed an NFS share on another machine: doesn’t that need some credentials, and doesn’t the NFS driver need some device configuration to point to a specific path on that remote server?

Please show the full details (with any password redacted) of the volume configuration.

(Please don’t post text as images, but just copy the configuration and error message. Thanks.)

1 Like

Thanks for your response avbentem,

This is my docker-compose.yml

version: '3'
services:
    proxy:
        image: optaros/ssl-termination-proxy:latest
        container_name: ${PROJECT_PREFIX}_docker_termination_proxy
        ports:
            - "443:443"
        environment:
            HOST_IP: varnish
            PORT: 80
        networks:
            - magento2
        depends_on:
            - varnish
    varnish:
        image: (secret-company)
        container_name: ${PROJECT_PREFIX}_docker_varnish
        ports:
            - "80:80"
        environment:
            VIRTUAL_HOST: web
            VIRTUAL_PORT: 8080
            VIRTUAL_HOST_ASQATASUN: web
            VIRTUAL_PORT_ASQATASUN: 8085
        networks:
            - magento2
        depends_on:
            - web
    web:
        image: optaros/m2-docker-nginx
        container_name: ${PROJECT_PREFIX}_docker_web
        ports:
            - "8085:8080"
            - "8443:8443"
        volumes:
            - nfsmount:/var/www/html
            - sock:/sock
            - mediavol:/var/www/html/pub/media
        environment:
            - NGINX_HOST=${NGINX_HOST}
        tty: true
        links:
            - redis
            - php
        depends_on:
            - php
            - db
            - redis
            - media
        networks:
          - magento2
    php:
        image: optaros/m2-docker-php-fpm
        privileged: true
        container_name: ${PROJECT_PREFIX}_docker_php
        environment:
            PHP_IDE_CONFIG: serverName=${PHP_STORM}
            XDEBUG_CONFIG: idekey=PHPSTORM
            COMPOSER_HOME: /composer
            CONFIG__STORES__ADMIN__WEB__UNSECURE__BASE_URL: https://website-url.local/
            CONFIG__STORES__ADMIN__WEB__SECURE__BASE_URL: https://website-url.local/
            CONFIG__DEFAULT__WEB__UNSECURE__BASE_URL: https://website-url.local/
            CONFIG__DEFAULT__WEB__SECURE__BASE_URL: https://website-url.local/
            CONFIG__STORES__ADMIN__ADMIN__URL__CUSTOM_PATH: magentoadmin
            CONFIG__STORES__ADMIN__ADMIN__URL__USE_CUSTOM_PATH: 1
            CONFIG__STORES__DEFAULT__ADMIN__URL__USE_CUSTOM: 1
            CONFIG__STORES__DEFAULT__ADMIN__URL__CUSTOM: https://website-url.local/magentoadmin/
            CONFIG__DEFAULT__PCM__API__WSDL_URL: http://website-url.com/pcm-webservices/WebServicePCM.asmx?wsdl
            CONFIG__DEFAULT__DEV__STATIC__SIGN: 1
            CONFIG__DEFAULT__DEV__JS__MERGE_FILES: 0
            CONFIG__DEFAULT__DEV__JS__ENABLE_JS_BUNDLING: 1
            CONFIG__DEFAULT__DEV__CSS__MINIFY_FILES: 0
            CONFIG__DEFAULT__DEV__CSS__MERGE_CSS_FILES: 1
            CONFIG__DEFAULT__DEV__GRID__ASYNC_INDEXING: 1
        volumes:
            - ~/.ssh:/root/.ssh:cached
            - ~/.composer:/composer
            - nfsmount:/var/www/html
            - sock:/sock
            - mediavol:/var/www/html/pub/media
        links:
            - db
            - redis
        depends_on:
          - db
          - redis
          - media
        networks:
          - magento2
    db:
        image: (secret-company)/ndg-m2-docker-db:${ENVIRONMENT}
        container_name: ${PROJECT_PREFIX}_docker_db
        env_file:
            - ".env"
        environment:
            - MYSQL_DATABASE=${MYSQL_DATABASE}
            - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
            - MYSQL_USER=${MYSQL_USER}
            - MYSQL_PASSWORD=${MYSQL_PASSWORD}
        ports:
            - "3306:3306"
        networks:
          - magento2
    media:
        image: (secret-company)/ndg-m2-docker-media:${ENVIRONMENT}
        container_name: ${PROJECT_PREFIX}_docker_media
        volumes:
          - mediavol:/var/www/html/pub/media
    redis:
        image: redis:5.0.5
        container_name: ${PROJECT_PREFIX}_docker_redis
        env_file:
            - ".env"
        volumes:
            - redis:/data
        tty: true
        networks:
          - magento2
    rabbitmq:
        image: bitnami/rabbitmq:latest
        container_name: ${PROJECT_PREFIX}_docker_rabbitmq
        labels:
            kompose.service.type: nodeport
        ports:
            - '4369:4369'
            - '5672:5672'
            - '25672:25672'
            - '15672:15672'
        volumes:
            - 'rabbitmq_data:/bitnami'
        environment:
            - RABBITMQ_USERNAME=magento2
            - RABBITMQ_PASSWORD=magento2
            - RABBITMQ_VHOST=magento2
        networks:
          - magento2
    mailhog:
      container_name: ${PROJECT_PREFIX}_docker_mailhog
      image: mailhog/mailhog:v1.0.0
      ports:
        - "1025:1025"
        - "8025:8025"
      networks:
        - magento2
#    elasticsearch:
#        image: elasticsearch:1.7
#        container_name: ${PROJECT_PREFIX}_docker_elasticsearch
#        restart: always
#        ports:
#          - 9200
#          - 9300
volumes:
    nfsmount:
        driver: local
        driver_opts:
            type: nfs
            o: addr=host.docker.internal,rw,nolock,hard,nointr,nfsvers=3
            device: ":PROJECT_DIR"
    mediavol: {}
    redis: {}
    rabbitmq_data:
        driver: local
    mysql:
    sock:

networks:
  magento2:
    driver: bridge

And these are my settings in docker desktop

In macOs, there is a similar issue and the fix is moving the cloned folder from /Users/username/Documents to /Users/username/anyfolder

Thanks!

I still suspect you’re trying to access a local folder?

Yes. It’s a local folder within WSL2
folder location of docker-compose.yml in Windows: \wsl$\Ubuntu-20.04\home\cian\xxxx\ndgm-platform\docker
folder location of docker-compose.yml in WSL2: /home/cian/xxxx/ndgm-platform/docker

I may be wrong, as Windows and WSL2 are not my strong suit, but:

I don’t know much about WSL2, but I doubt you should use NFS for that. To use a local NFS share, your local machine should somehow be running the NFS server software and share the folder (maybe that’s just plain Windows functionality; I don’t know much about that either), to which Docker then connects using its built-in client software. (And if that should work out of the box, then I still expect some device settings to specify the NFS share name.)

But: I feel all you need is a bind mount (just like you’re already doing for ~/.composer:/composer), to make some local folder available to your container(s).

Did you see “Use bind mounts” in the Getting Started?