'Bash script $path variable and $(pwd) behaves different with exakt same path
Why does this command copy everything in the frontend/ directory to the docker container...
docker run -it --rm -d -p 8080:80 --name webserver -v $( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/frontend/:/var/www/icebear.se -v $( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/nginx/webserver.conf:/etc/nginx/sites-enabled/icebear.se webserver
... and this command is only copying the directory frontend/ without its content?
read -e mypath
docker run -it --rm -d -p 8080:80 --name webserver -v $mypath/frontend/:/var/www/icebear.se -v "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/nginx/webserver.conf:/etc/nginx/sites-available/icebear.se webserver
If i echo $( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P ) i get this /Users/gnusson/Documents/GitHub/dockerized-webserver
If i run my second command instead and echo $mypath i get this /Users/gnusson/Documents/GitHub/dockerized-webserver
Exact the same, but for some reason behaves different.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
