Reputation: 3238
I'm running Nginx
inside Docker
and from logs, I can see that Nginx
cannot find mime.types file.
The line from Nginx.conf:
include mime.types;
Here is the Dockerfile
.
FROM nginx:alpine
COPY . ./etc/nginx
RUN ls -la /etc/nginx
Here is the list of files in the working directory:
drwxr-xr-x 1 root root 4096 Jul 30 07:35 .
drwxr-xr-x 1 root root 4096 Jul 30 07:35 ..
-rw-r--r-- 1 root root 58 Jul 29 21:48 Dockerfile
drwxr-xr-x 2 root root 4096 Jul 29 21:36 certs
drwxr-xr-x 2 root root 4096 Jul 6 19:40 conf.d
-rw-r--r-- 1 root root 1077 Jul 6 15:21 fastcgi.conf
-rw-r--r-- 1 root root 1007 Jul 6 15:21 fastcgi_params
-rw-r--r-- 1 root root 5290 Jul 6 15:21 mime.types
lrwxrwxrwx 1 root root 22 Jul 6 19:40 modules -> /usr/lib/nginx/modules
-rw-r--r-- 1 root root 10729 Jul 30 07:35 nginx.conf
-rw-r--r-- 1 root root 636 Jul 6 15:21 scgi_params
-rw-r--r-- 1 root root 664 Jul 6 15:21 uwsgi_params
And this is the error log:
2021/07/30 07:35:34 [emerg] 1#1: open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:52
I can clearly see that nginx.conf is in the same directory but couldn't be found.
Docker compose
version: "3.7"
services:
proxy:
build: nginx
container_name: nginx
ports:
- '443:443'
volumes:
# - ./nginx:/etc/nginx
# - /etc/nginx/certs
restart: 'always'
networks:
- react-express
frontend:
build: ui
expose:
- 3000
stdin_open: true
volumes:
- ./ui:/usr/src/ui
- /usr/src/ui/node_modules
container_name: ui
restart: always
networks:
- react-express
depends_on:
- backend
backend:
container_name: api
restart: always
build: api
volumes:
- ./api:/usr/src/app
- /usr/src/app/node_modules
networks:
- react-express
expose:
- 8080
networks:
react-express:
Upvotes: 0
Views: 3734
Reputation: 25070
As you say in the comment, you map a directory to /etc/nginx
when you run the container.
When you map ./nginx:/etc/nginx
, the volume mapping wins and 'hides' the files in the image.
Upvotes: 1