Error Deploying Nginx on Docker: Mounting Path Issue with Nginx.conf

I am trying to deploy nginx on docker container, I received this error:

unable to start container process: error during container init: error mounting "/data/compose/158/docker/nginx/nginx.conf" to rootfs at "/etc/nginx/nginx.conf": mount /data/compose/158/docker/nginx/nginx.conf:/etc/nginx/nginx.conf (via /proc/self/fd/6), flags: 0x5001: not a directory: unknown: 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.

here is the content of docker-compose.yml

services:
  nginx:
    image: nginx:latest
    container_name: superset_nginx
    restart: unless-stopped
    ports:
      - "81:81"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro

Confirmed that the file ./docker/nginx/nginx.conf exists in the project directory.
Verified that the path is correct relative to the docker-compose.yml file. Project files and dics are like:

project
-docker
--nginx
---nginx.conf
-docker-compose.yml

What could be causing this error, and how do I fix it? Is there a mismatch between the expected file type and the host path?

Read more here: Source link