不支持直接挂载文件,会生成与文件同名的目录,导致挂载失败,报错信息如下:
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/var/prometheus" to rootfs at "/etc/prometheus/prometheus.yml": mount /var/prometheus:/etc/prometheus/prometheus.yml (via /proc/self/fd/6), flags: 0x5000: 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
解决方法:先在挂载目录下新建文件,然后再创建并运行容器,例如:
进入挂载目录:cd /var/prometheus
新建待挂载文件:touch prometheus.yml
创建并运行容器:
docker run --name=prometheus -d -p 9090:9090 --restart=always -v /var/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
标签:容器,文件,prometheus,var,挂载,docker,yml From: https://www.cnblogs.com/sheepboy/p/17246741.html