Docker运行Prometheus挂载自定义yml失败:OCI runtime创建错误
问题解决步骤
核心错误原因
你使用的主机路径/tmp/prometheus.yml与实际文件所在的D:\Projects\Msc-Thesis-Project\tmp路径不匹配,且Windows环境下Docker挂载文件需要特定路径格式,导致Docker无法定位到目标文件,触发了“挂载类型不匹配”的错误。
修正后的命令
根据你使用的终端环境,选择对应命令执行:
1. Git Bash/WSL终端
将Windows盘符转为小写,反斜杠替换为斜杠:
docker run --net=host \ -v /d/Projects/Msc-Thesis-Project/tmp/prometheus.yml:/etc/prometheus/prometheus.yml \ prom/prometheus
2. PowerShell/CMD终端
用引号包裹路径,保留Windows路径格式:
docker run --net=host ` -v "D:/Projects/Msc-Thesis-Project/tmp/prometheus.yml:/etc/prometheus/prometheus.yml" ` prom/prometheus
额外检查项
- 确认
prometheus.yml文件确实存在于D:\Projects\Msc-Thesis-Project\tmp目录下,文件名无拼写错误(容器内路径区分大小写,尽量保持文件名一致)。 - 打开Docker Desktop设置,进入Resources -> File Sharing,勾选D盘,保存后重启Docker,确保Docker有权限访问该路径下的文件。
内容的提问来源于stack exchange,提问作者Alex_Pap
相关产品推荐
相关产品推荐

