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创建的elasticsearch容器添加密码简单步骤
在使用Elasticsearch(ES)Docker容器时,有时需要设置密码来保护数据的安全性,这篇文章主要给大家介绍了关于给docker创建的elasticsearch容器添加密码的简单步骤,需要的朋友可以参考下2024-02-02
docker maven plugin快速部署微服务的详细流程
本文给大家介绍docker maven plugin微服务快速部署方法,主要将Dockerfile写在pom中方便项目管理,将微服务的 打包、上传、镜像创建操作整合到一条命令中执行,感兴趣的朋友跟随小编一起看看吧2022-04-04
使用 Docker 搭建 Laravel 本地环境的教程详解
laradock 是一个包含全功能用于 docker 的 PHP 运行环境,使用 docker-compose 方式部署,本文重点给大家介绍使用 Docker 搭建 Laravel 本地环境的方法,感兴趣的朋友一起看看吧2017-10-10


最新评论