First of all, I am only experiencing this issue on my Linux VPS. This issue doesn't exist on my Windows development machine.
My VPS is running Ubuntu 23.04
The issue
When I attempt to launch my docker container from a docker-compose script, the Nginx continer errors and spits out this:
root@srv502529:/docker_projects/personal-site-2024# docker-compose upCreating network "personal-site-2024_default" with the default driverCreating personal-site-2024_api_proxy_server_1 ... doneCreating personal-site-2024_webserver_1 ... doneCreating personal-site-2024_cms_server_1 ... doneCreating personal-site-2024_nginx_1 ... errorERROR: for personal-site-2024_nginx_1 Cannot start service nginx: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/nginx.conf" to rootfs at "/etc/nginx/nginx.conf": mount /nginx.conf:/etc/nginx/nginx.conf (via /proc/self/fd/6), flags: 0x5000: 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 typeERROR: for nginx Cannot start service nginx: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/nginx.conf" to rootfs at "/etc/nginx/nginx.conf": mount /nginx.conf:/etc/nginx/nginx.conf (via /proc/self/fd/6), flags: 0x5000: 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 typeI think the common cause of this is that nginx.conf isn't where it's specified, but in my case it absolutely is:screenshot of my project directory via SSHscreenshot of my project directory VIA SFTP
Snippet of docker-compose
services: nginx: image: nginx:alpine ports: - "80:80" volumes: - /nginx.conf:/etc/nginx/nginx.conf depends_on: - webserver - api_proxy_server - cms_serverWhat I've tried
I've tried using this volume mapping ./nginx:/etc/. It apparently loads and I get a done message in the console, but then I get this error:
nginx_1 | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configurationnginx_1 | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/nginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.shnginx_1 | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not existnginx_1 | /docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envshnginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.shnginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.shnginx_1 | /docker-entrypoint.sh: Configuration complete; ready for start upnginx_1 | 2024/04/08 15:35:46 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)nginx_1 | nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)