Unix:调用脚本的bash脚本和相对路径

3

I have the following directory structure

.
|_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.

如何保留相对路径与调用脚本的位置相关?
1个回答

1
稍微不同的方法,但可能有效。在您的顶级build.sh文件中添加以下内容:
#!/bin/bash
cd ./dir
docker build -t test .

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接