Tuomas Toivonen
Tuomas Toivonen

Reputation: 23502

Unix: bash script calling script, and relative paths

I have the following directory structure

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

Here is the content of upper level build.sh

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

and here is the content of bottom level build.sh

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

However, when I run upper level build.sh I get the following error

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

How do I preserve the relative path relative to the location of the script being called?

Upvotes: 3

Views: 240

Answers (1)

Robert
Robert

Reputation: 36813

Slightly different approach but might work. This in your top level build.sh:

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

Upvotes: 1

Related Questions