【问题标题】:swarm mode doesn't recognize absolute path in windowsswarm 模式无法识别 Windows 中的绝对路径
【发布时间】:2021-01-19 13:55:28
【问题描述】:

我正在关注 Bret Fisher 的 docker 课程,我得到了this assignment。我在 Windows 上运行并使用 docker-machine 创建了 3 个虚拟节点。所有三个节点都连接成一个集群(2 个管理器,1 个工作人员)。我正在尝试运行以下命令:

docker service create --network backend --mount type=volume,source=db-data,target=/var/lib/postgresql/data --name db -e POSTGRES_HOST_AUTH_METHOD=trust postgres:9.4

当我在 powershell 中运行时,它工作正常。 当我尝试在 GitBash 或 cmder 中运行它时,出现错误:

invalid mount target, must be an absolute path <the path of cli in used>

我尝试将目标更改为:

  1. 不同的路径
  2. pwd/ $pwd / $(pwd) / ${pwd}
  3. wsl wslpath $(pwd)

附言 当我运行相同代码的the stack example 时,它确实在 GitBash/Cmder 和 powershell 中运行。

【问题讨论】:

    标签: powershell docker-swarm git-bash docker-machine cmder


    【解决方案1】:

    您是否尝试引用挂载值?

    docker service create --network backend --mount "type=volume,source=db-data,target=/var/lib/postgresql/data" --name db -e POSTGRES_HOST_AUTH_METHOD=trust postgres:9.4
    

    【讨论】:

    • 是的,我试过带引号和不带引号(双引号和单引号)。这感觉像是环境问题或错误
    【解决方案2】:

    检查您是否在包含空格的目录中工作。

    当使用挂载和卷 (-v) 时,无论您尝试使用哪种转义字符,Docker 都无法在 Windows 上使用 Bash 处理这种情况。

    我发现解决此问题的唯一方法是将当前目录切换到其中没有文件夹包含空格的目录。

    即使在-v 输入中使用$(pwd) 也是一个问题,请参阅here,还有一个我尝试使用的转义字符列表来解决问题。

    【讨论】:

      猜你喜欢
      • 2021-09-02
      • 2020-08-16
      • 1970-01-01
      • 2020-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-18
      • 1970-01-01
      相关资源
      最近更新 更多