【问题标题】:Unix: bash script calling script, and relative pathsUnix:bash 脚本调用脚本和相对路径
【发布时间】:2018-09-21 00:05:38
【问题描述】:

我有以下目录结构

.
|_build.sh
|_dir
  |_build.sh
  |_Dockerfile

这里是上层build.sh的内容

#!/bin/bash
./dir/build.sh

这是底层build.sh的内容

#!/bin/bash
docker build -t test .

但是,当我运行上层 build.sh 时,出现以下错误

unable to prepare context: unable to evaluate symlinks in Dockerfile path: GetFi
leAttributesEx C:\Dockerfile: The system cannot find the fil
e specified.

如何保留相对于被调用脚本位置的相对路径?

【问题讨论】:

    标签: linux bash shell unix docker


    【解决方案1】:

    方法略有不同,但可能有效。这在您的顶级 build.sh 中:

    #!/bin/bash
    cd ./dir
    docker build -t test .
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-14
      • 1970-01-01
      • 2013-02-02
      • 1970-01-01
      • 2016-01-09
      • 1970-01-01
      • 1970-01-01
      • 2018-02-25
      相关资源
      最近更新 更多