Ubuntu 23.04 VPS中Docker挂载nginx.conf文件失败问题求助
Ubuntu 23.04 VPS上Docker挂载Nginx配置文件失败
我在运行Ubuntu 23.04的Linux VPS上尝试将本地nginx.conf文件挂载到Docker容器对应路径,挂载配置./nginx.conf:/etc/nginx/nginx.conf:ro在macOS(Docker v25.0.3)和Windows 11上可正常工作,但在VPS上执行时出现如下错误:
ERROR: 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 "/docker_projects/personal-site-2024/nginx.conf" to rootfs at "/etc/nginx/nginx.conf": mount /docker_projects/personal-site-2024/nginx.conf:/etc/nginx/nginx.conf (via /proc/self/fd/6), flags: 0x5001: 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 "/docker_projects/personal-site-2024/nginx.conf" to rootfs at "/etc/nginx/nginx.conf": mount /docker_projects/personal-site-2024/nginx.conf:/etc/nginx/nginx.conf (via /proc/self/fd/6), flags: 0x5001: 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.
我将nginx.conf放入nginx_conf目录并使用/nginx_conf:/etc/nginx/conf.d映射时无报错,但容器内conf.d目录中不出现该文件。nginx.conf文件权限为-rwxr-xr-x 1 root root 1009 Apr 9 14:49 nginx.conf。
已尝试操作:
- 将文件重命名为
default.conf - 调整为目录映射
附docker-compose.yml片段:
version: '3' services: # This makes the dockerised containers publicly accessible so that # runtime fetch requests made by the webserver (in browser) reach # the containers sequestered in the docker network through forwarding nginx: image: nginx:alpine ports: - "80:80" volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro depends_on: - webserver - api_proxy_server - cms_server
内容的提问来源于stack exchange,提问作者Hayden Gorringe
相关产品推荐
相关产品推荐

