Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git Bash problem with path when creating mount #187

Open
K-C-Martin opened this issue May 21, 2022 · 4 comments
Open

Git Bash problem with path when creating mount #187

K-C-Martin opened this issue May 21, 2022 · 4 comments

Comments

@K-C-Martin
Copy link

Lesson: Advanced Containers
Permalink: https://github.com/carpentries-incubator/docker-introduction/blob/0aed5fb0263e779cf807bd649fe6f9ce626d0407/_episodes/advanced-containers.md

I'm using Git Bash on Windows 10 Enterprise.

When I try to run the following (following the Advanced Containers lesson):

docker container run --mount type=bind,source=${PWD},target=/temp alpine-python python3 /temp/sum.py

... I get the following error:

python3: can't open file '//C:/Program Files/Git/temp/sum.py': [Errno 2] No such file or directory

Prepending a / as suggested in the Setup (/${PWD}) doesn't fix the problem, but running the following first does:

export MSYS_NO_PATHCONV=1

@K-C-Martin K-C-Martin changed the title Git Bash Git Bash problem with path when creating mount May 21, 2022
K-C-Martin added a commit to K-C-Martin/docker-introduction that referenced this issue May 21, 2022
@aturner-epcc
Copy link
Contributor

Thanks for this @K-C-Martin. The issue with git bash is already noted in the setup.md file and it also gives people a workaround:

Warning: Git Bash

If you are using Git Bash as your terminal on Windows then you should be aware that you may run
into issues running some of the commands in this lesson as Git Bash will automatically re-write
any paths you specify at the command line into Windows versions of the paths and this will confuse
the Docker container you are trying to use. For example, if you enter the command:

docker run alpine cat /etc/os-release

Git Bash will change the /etc/os-release path to C:\etc\os-release\ before passing the command
to the Docker container and the container will report an error. If you want to use Git Bash then you
can request that this path translation does not take place by adding an extra / to the start of the
path. i.e. the command would become:

docker run alpine cat //etc/os-release

This should suppress the path translation functionality in Git Bash.

We could add a callout with this information again in the lessons to remind people if you think this would be useful.

@K-C-Martin
Copy link
Author

Hi @aturner-epcc - I did try adding an extra / to ${PWD}, but it didn't seem to work... I got the same error message.

@K-C-Martin
Copy link
Author

K-C-Martin commented May 21, 2022

See the following series of attempts:

kcmartin@bosbou504824 MINGW64 ~/Desktop/docker-intro/sum
$ docker container run --mount type=bind,source=${PWD},target=/temp alpine-python python3 /temp/sum.py
python3: can't open file '//C:/Program Files/Git/temp/sum.py': [Errno 2] No such file or directory

kcmartin@bosbou504824 MINGW64 ~/Desktop/docker-intro/sum
$ docker container run --mount type=bind,source=/${PWD},target=/temp alpine-python python3 /temp/sum.py
python3: can't open file '//C:/Program Files/Git/temp/sum.py': [Errno 2] No such file or directory

kcmartin@bosbou504824 MINGW64 ~/Desktop/docker-intro/sum
$ docker container run --mount type=bind,source="/${PWD}",target=/temp alpine-python python3 /temp/sum.py
python3: can't open file '//C:/Program Files/Git/temp/sum.py': [Errno 2] No such file or directory

kcmartin@bosbou504824 MINGW64 ~/Desktop/docker-intro/sum
$ export MSYS_NO_PATHCONV=1

kcmartin@bosbou504824 MINGW64 ~/Desktop/docker-intro/sum
$ docker container run --mount type=bind,source=${PWD},target=/temp alpine-python python3 /temp/sum.py
sum = 0

@K-C-Martin
Copy link
Author

K-C-Martin commented May 23, 2022

Ah - I'm pretty sure I tried prepending / to /temp/sum.py too, with the same results, but let me confirm that.

p.s. it may take me a while to run this check - I've managed to break the machine I had got Docker running on.

p.p.s. in the meantime, let me say 'thank you' for this material: really, really appreciated having such a clear, practical walkthrough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants