栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Go语言

Error response from daemon: OCI runtime create failed: container

Go语言 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Error response from daemon: OCI runtime create failed: container

docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused “process_linux.go:424: container init caused “rootfs_linux.go:58: mounting ”/docker/nginx/conf” to rootfs "/var/lib/docker/overlay2/126c244dc6ee7095b1501a503eb361bade4fc255601ec0b0fe96238b58178958/merged" at "/var/lib/docker/overlay2/126c244dc6ee7095b1501a503eb361bade4fc255601ec0b0fe96238b58178958/merged/etc/nginx/nginx.conf" caused “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:

docker run -d -p 80:80 --name nginx --net host -v /home/web/dist:/usr/share/nginx/html  -v /home/nginx/logs:/var/log/nginx nginx

命令说明:
-p 8081:80: 将容器的 80 端口映射到主机的 8081 端口。
–name nginx :将容器命名为 nginx 。
–net host :启动模式 建议使用 否则做负载均衡会有问题!
-v /home/web/dist:/usr/share/nginx/html:将我们自己创建的 www 目录挂载到容器的 /usr/share/nginx/html。
-v /home/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:将我们自己创建的 nginx.conf 挂载到容器的 /etc/nginx/nginx.conf。
-v /home/nginx/logs:/var/log/nginx:将我们自己创建的 logs 挂载到容器的 /var/log/nginx

报错了头大:docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused “process_linux.go:424: container init caused “rootfs_linux.go:58: mounting ”/docker/nginx/conf/nginx.conf” to rootfs "/var/lib/docker/overlay2/73ad6cfead8c2d9c1d25469cccff7d86029ce6308a83416b2ef08464c8c5f76f/merged" at "/var/lib/docker/overlay2/73ad6cfead8c2d9c1d25469cccff7d86029ce6308a83416b2ef08464c8c5f76f/merged/etc/nginx/nginx.conf" caused “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.

解决办法:
换一种方法不启动 -v /docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf 这个
启动之前先把刚刚已经启动的容器删除 docker rm -f nginx 然后记得删除掉/docker/nginx/conf/nginx.conf(注意这里帮你创建了个目录需要也删除 然后在执行下面命令其他不管)

docker run -d -p 80:80 --name nginx --net host -v /home/web/dist:/usr/share/nginx/html  -v /home/nginx/logs:/var/log/nginx nginx


然后发现没错 正常启动

访问80端口:

访问可能会403 因为/home/web/dist 里面没有index.html放进去就好了

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/904522.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号