Docker Community Forums

Share and learn in the Docker community.

Mount volumes from windows host, nginx

I am trying to mount a local directory to a container to allow local configuration of a nginx reverse proxy.

version: ‘3.7’
image: nginx:alpine
container_name: nginx-proxy
- “80:80”
- “443:443”
- ./nginx/conf:/etc/nginx
- ./nginx/cert:/etc/ssl/private

As outlined here

docker should create a bunch of lokal files. However, it creates the directories but comes up with an error message - nginx: [emerg] open() “/etc/nginx/nginx.conf” failed (2: No such file or directory)

I am unclear if now docker creates those files locally - retrieving them from the container? But why does it state that the nginfx.conf does not exist?


The config file has to exist, it is not created. If you mount a local folder into the container the content of /etc/nginx is replaced, that’s the normal behavior of mount.
In the docs for the nginx image you see under “Complex configuration” how you can copy the default config to your local drive to edit it afterwards.

Thank you - it all worked out.