Nginx mounting volumes issue

This line in docker-compose.yml file:
- /rancher-nfs/nginx/nginx.conf:/etc/nginx/conf.d/default.conf

cause this issue:
Activating (Expected state running but got error: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused “process_linux.go:359: container init caused “rootfs_linux.go:54: mounting \”/rancher-nfs/nginx/nginx.conf\” to rootfs \"/var/lib/docker/overlay/e4cadcb773b96bbf5b0162a247ad4816de5197985693b556cb2db467daad897c/merged\" at \"/var/lib/docker/overlay/e4cadcb773b96bbf5b0162a247ad4816de5197985693b556cb2db467daad897c/merged/etc/nginx/conf.d/default.conf\" caused \“not a directory\”"" : Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type)

I do not know why…

Is “/rancher-nfs/nginx/nginx.conf” a local directory on the host?
By the name, it sounds like you are trying to use rancher-nfs as the source? If so, then you need to have a separate volumes: declaration.

Here’s an example (Rancher 1.6.3)

version: '2'
    external: true
    driver: rancher-nfs
    image: ubuntu:16.04
    stdin_open: true
    - sleep
    - infinity
    - ubuntu-test-volume:/opt/test/volume
    tty: true
      io.rancher.container.pull_image: always

Could you please explain why?

Ihave noticed that this line goes without error even if not have “seperate volume declaration”

Any light in the tunnel? I do not like to do things I do not understand why and what for…

At the same time I had no erorr with volume declaration like

  • /rancher-nfs/mariadb_data:/var/lib/mysql for mysql
    /rancher-nfs/app:/app for php-fpm

Are you, in fact, trying to use rancher-nfs as the source for the volume?

When you specify a volume, you specify a source and a target within the container, separated by a colon. In your config, you are using “/rancher-nfs/nginx/nginx.conf” as the source, so docker is going to look on the host’s local filesystem in that directory. If that directory doesn’t exist on the host, then you would get an error.

If you want to use rancher-nfs, then you need to have the named volume and tell Rancher that the volume needs to use the rancher-nfs driver to access the source.