Docker Daemon is not able to create nginx config file

Background:

  1. Running Linux Containers on Docker
  2. Using WSL2
  3. Running a flask app on Docker - succeeded
  4. Built a nginx config file and that fails while doing docker-compose

nginx.config file is as follows:

events {
    worker_connections 1000;
}

http {
    server {
        listen 80;

        location / {
            proxy_pass http://app:5000
        }
    }
}

docker-compose yml is as follows:

version: '3'

services:
    app:
        build:
            context: app
        ports:
            - "5000"
    
    nginx:
        image: nginx:latest
        volumes:
            - ./nginx.conf:/etc/nginx/nginx.conf:ro
        depends_on:
            - app
        ports:
            - "80:80"
        

while executing this: docker-compose up -d --build --scale app=3

My error is: Error response from daemon: CreateFile pathspecified\nginx.conf: Access is denied.

I researched and it said WSL2 automatically shares all files from windows, so I am not able to get why this error comes after I create nginx.config? How can I fix this?

It says access denied, not not found. So it seems to be a permission issue.

This “CreateFile” kind of error message is new to me, but the Docker Daemon shouldn’t create any file when you just wan to mount one. If the nginx.conf file is in the folder where you run docker compose, that should work. What was “pathspecified” originall? Was it the actual path of your compose project plus the nginx config or something else?

yes, the path to nginx.conf file and docker compose file is the same.

I am not working from an admin account, can that be it?