【问题标题】:docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545:docker:来自守护进程的错误响应:OCI 运行时创建失败:container_linux.go:380:启动容器进程导致:process_linux.go:545:
【发布时间】:2022-04-29 22:13:03
【问题描述】:

我在执行下一个 docker 指令时遇到问题:

# make a directory
mkdir /server/nginx
cd /server/nginx

 # make a container
docker run --name nginx \
-d -p 8080:8080 \
-v /home/www:/home/www \
-v /home/www:/usr/share/nginx/html \
-v "$PWD"/nginx.conf:/etc/nginx/nginx.conf \
-v "$PWD"/logs:/var/log/nginx \
-v "$PWD"/conf.d:/etc/nginx/conf.d \
--link php \
-d nginx

我得到下一个错误

docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/server/nginx/nginx.conf" to rootfs at "/etc/nginx/nginx.conf" caused: mount through procfd: 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. 

Docker 生成了下一个目录:

drwxr-xr-x 5 根 4096 1 月 7 日 05:03 ./
drwxr-xr-x 8 根 4096 1 月 7 日 04:49 ../
drwxr-xr-x 2 根4096 Jan 7 05:03 conf.d/
drwxr-xr-x 2 root root 4096 Jan 7 05:03 logs/
drwxr-xr-x 2 root root 4096 Jan 7 05:03 nginx.conf/

什么时候需要文件而不是目录。

【问题讨论】:

    标签: docker nginx


    【解决方案1】:

    drwxr-xr-x 2 root root 4096 Jan 7 05:03 nginx.conf/

    上面的d 表示nginx.conf 不是一个文件,而是一个文件夹。您可以尝试cd nginx.conf 进行验证。

    如错误所示,您应该设置nginx.conf 文件,而不是nginx.conf 文件夹。

    【讨论】:

    • 是的。它是一个文件夹。但是这些文件是 docker 生成的...
    • 你定义-v "$PWD"/nginx.conf:/etc/nginx/nginx.conf,因为你要自定义nginx.conf,所以请删除文件夹,在docker run之前定义你自己的nginx.conf。或者,如果您不想自定义 nginx.conf,请删除该 -v
    • 如果我不想要文件夹 nginx,如何自定义 nginx.conf?我做了 nginx/-logs/-conf.d/--nginx.conf 但同样的错误:docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/server/nginx/logs" to rootfs at "/var/log/nginx" caused: mount through procfd: 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.
    • 我想添加nginx.conf 可以自定义、查看日志和文件conf.d
    • 根据你的设置,你首先需要rm -fr /server/nginx/nginx.conf,然后vim /server/nginx/nginx.conf,在这个文件中添加东西。
    【解决方案2】:

    我从一个位置启动了一个先前安装了卷的容器,而我同时分配了另一个位置。从一开始就删除并重新创建容器,绑定/挂载一个新的卷路径后,它工作了。

    【讨论】:

      猜你喜欢
      • 2021-10-08
      • 1970-01-01
      • 1970-01-01
      • 2018-05-28
      • 1970-01-01
      • 2021-08-22
      • 2019-04-30
      • 2020-01-11
      • 1970-01-01
      相关资源
      最近更新 更多