version: "3"
services:
nginx:
container_name: nginx
image: nginx:latest
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./fastapi_example.conf:/etc/nginx/conf.d/
ports:
- 80:80
fastapi_example.conf 是我的本地文件
我想放到容器的 /etc/nginx/conf.d/ 路径下,但是报错了
╰─➤ docker-compose up -d
Recreating nginx ... error
ERROR: 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 "/home/pon/opt/docker-compose-public/nginx/fastapi_example.conf" to rootfs at "/etc/nginx/conf.d": mount /home/pon/opt/docker-compose-public/nginx/fastapi_example.conf:/etc/nginx/conf.d (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 type
ERROR: 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 "/home/pon/opt/docker-compose-public/nginx/fastapi_example.conf" to rootfs at "/etc/nginx/conf.d": mount /home/pon/opt/docker-compose-public/nginx/fastapi_example.conf:/etc/nginx/conf.d (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 type
ERROR: Encountered errors while bringing up the project.
我们挂载的时候都是具体到文件。比如用本地的global.js文件替换容器里面的global.js文件