【问题标题】:Invalid mount config for type "bind": bind source path does not exist when trying to run container on Docker for Windows“绑定”类型的挂载配置无效:尝试在 Docker for Windows 上运行容器时绑定源路径不存在
【发布时间】:2018-01-22 11:29:39
【问题描述】:

我正在尝试在 Windows 上使用 Docker 在https://docs.docker.com/engine/admin/prometheus/#use-prometheus 运行 Prometheus 示例。我正在执行以下命令:

docker service create --replicas 1 --name my-prometheus `
   --mount type=bind,source="C:/temp/prometheus.yml",destination=/etc/prometheus/prometheus.yml `
   --publish published=9090,target=9090,protocol=tcp `
   prom/prometheus

错误是:invalid mount config for type "bind": bind source path does not exist

我很确定该文件存在(Test-Path 使用 PowerShell 返回 true)。

知道我做错了什么吗?

更新

使用mount type = volume 运行相同的命令会出现以下错误:

C:/temp/prometheus.yml”包含本地卷名的无效字符,仅允许使用“[a-zA-Z0-9][a-zA-Z0-9_.-]”。如果您打算传递主机目录,请使用绝对路径"

我正在传递一个主机目录,"C:/temp/prometheus.yml" 是一个绝对路径。

【问题讨论】:

  • 如果您将挂载类型更改为卷 --mount type=volume。 Mount type=bind should be used on --mount type=bind,source=/path/on/host,destination=/path/in/container
  • @RanadipDutta 谢谢 试过了,但还是出错。查看更新后的帖子,
  • 你是否与 Docker 共享了 C 盘? docs.docker.com/docker-for-windows/#shared-drives
  • @BMitch 是的,我已经共享了 C 盘。

标签: powershell docker prometheus docker-for-windows


【解决方案1】:

更改 Windows 帐户密码后,您可能会在 Windows 上遇到此问题。

  1. 打开 Docker for Windows 设置。
  2. 在共享驱动器选项卡上单击重置凭据...
  3. 再次共享您的驱动器。

【讨论】:

  • 我在没有更改密码的情况下收到此错误,但在我的 Windows 10 机器每次重新启动后。您的解决方案有效,因此这是一种很好的解决方法。那么我该怎么做才能让 DDEV 和 Docker 不会忘记我的 Windows 凭据呢?
【解决方案2】:

我也遇到了同样的错误。如下图,取消选中“使用 Docker Compose V2”,它对我有用。我想分享一下,以防这可能是某人的解决方案

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多