docker 创建nginx容器时对配置文件进行挂载时报错,有那大佬热心提点提点!感谢感谢!!!!
docker 以及 ngixn镜像信息如下:
root@iZ28q62x60iZ:/srv/testServer# docker -v
Docker version 18.03.1-ce, build 9ee9f40
root@iZ28q62x60iZ:/srv/testServer# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 649dcb69b782 19 hours ago 109MB
root@iZ28q62x60iZ:/srv/testServer#
执行错误报如下错误:
root@iZ28q62x60iZ:/srv/testServer# docekr run --name nginx -d -p 80:80 -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf nginx
No command 'docekr' found, did you mean:
Command 'docker' from package 'docker.io' (universe)
docekr: command not found
root@iZ28q62x60iZ:/srv/testServer# docker run --name nginx -d -p 80:80 -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf nginx
4db2ddccc4022c305991a1dce568fd8332087d5543a56f4a573cde69de33feb8
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/srv/testServer/conf/nginx.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/3d4b01b3ed517480faba01aa1edb6fbb9e2dc01d5de5239e8c8d00d3a159777a/merged\\\" at \\\"/var/lib/docker/overlay2/3d4b01b3ed517480faba01aa1edb6fbb9e2dc01d5de5239e8c8d00d3a159777a/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.
root@iZ28q62x60iZ:/srv/testServer#
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一条命令,docker 拼错了。
第二条命令的报错信息很明显:
$PWD/conf/nginx.conf 是目录,而镜像中的 /etc/nginx/nginx.conf 是 regular file, volume mount 失败。
剩下怎么解决应该不用提示吧,该删删,该建建
建议仔细看下nginx镜像中配置文件的目录结构,比如 /etc/nginx/conf.d/, 如果只是增加 server block,不必修改默认设置