场景
使用DockerCompose编排项目时,其中nginx的服务的yml为
nginx: image: nginx:latest ports: - "390:390" volumes: - ./nginx/font/dist:/usr/share/nginx/dist - ./nginx/log:/var/log/nginx - ./nginx/config:/etc/nginx
当启动时查看nginx的日志
docker-compose logs nginx
提示:
/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:6
注:
博客:
https://blog.csdn.net/badao_liumang_qizhi
实现
1、这是因为挂载是整个/etc/nginx目录,但是这个目录里面只加了nginx.conf,
而容器中/etc/nginx目录下还有很多其他的文件,直接挂载了整个目录,其他的
文件就会消失,读取配置文件就会有问题。
所以只需要挂载nginx.conf文件即可。
2、将其修改为如下
nginx: image: nginx:latest ports: - "390:390" volumes: - ./nginx/font/dist:/usr/share/nginx/dist - ./nginx/log:/var/log/nginx - ./nginx/config/nginx.conf:/etc/nginx/nginx.conf
此时再查看时启动成功
标签:dist,DockerCompose,etc,nginx,390,conf,log From: https://www.cnblogs.com/badaoliumangqizhi/p/16990558.html