Docker挂载/etc/timezone报错问题
Docker挂载/etc/timezone报错
执行这段命令
docker run -d --name sys-app -v /etc/timezone:/etc/timezone -v /etc/localtime:/etc/localtime -p 8001:8001 --restart=always --net=host sys-app:latest
报如下错
docker: Error response from daemon: OCI runtime create failed: container_linux.go:346:
starting container process caused "process_linux.go:449: container init caused
\"rootfs_linux.go:58: mounting \\\"/etc/timezone\\\" to rootfs
\\\"/var/lib/docker/overlay2/cb6229f54bfa2ffb1fdb70a316606bf5936ebe69c7d0ee8d26da98b78c9
1e857/merged\\\" at
\\\"/var/lib/docker/overlay2/cb6229f54bfa2ffb1fdb70a316606bf5936ebe69c7d0ee8d26da98b78c9
1e857/merged/etc/timezone\\\" 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 run命令中的-v /etc/timezone变成了-v /etc/timezone/timezone
原因是centos7.6中/etc/timezone是一个文件夹,而不是一个文件
执行如下命令
echo 'Asia/Shanghai' > /etc/timezone/timezone
然后执行
docker run -d --name sys-app -v /etc/timezone/timezone:/etc/timezone -v /etc/localtime:/etc/localtime -p 8001:8001 --restart=always --net=host sys-app:latest
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
docker中Dockerfile方式建立镜像HelloWorld
这篇文章主要介绍了docker中Dockerfile方式建立镜像HelloWorld,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2017-07-07解决docker镜像(centos系统)中无sudo命令问题
这篇文章主要介绍了解决docker镜像(centos系统)中无sudo命令问题,具有很好的参考价值,希望对大家有所帮助,2023-11-11Spring Boot应用通过Docker发布部署的流程分析
将Spring Boot项目部署到docker中有两种方法,手动部署和插件部署,本文通过实例代码介绍了idea创建spring boot项目的详细过程,感兴趣的朋友一起看看吧2021-09-09Docker使用编写dockerfile启动node.js应用
这篇文章主要介绍了Docker使用编写dockerfile启动node.js应用,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2019-01-01
最新评论