Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git sh.exe & Docker run (no such file or directory)

Tags:

git

docker

I have ran into a perplexing problem and cannot seem to find an explanation.

  1. Run /usr/bin/sh.exe (this is sh.exe provided by Git for Windows)

  2. Execute the following command: docker run alpine:edge /bin/sh -c "echo AAA"

  3. Observe error (for readability I am subbing git-installation-path): docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "<git-installation-path>/usr/bin/sh": stat <git-installation-path>/usr/bin/sh: no such file or directory: unknown.

I don't understand why dockeris trying to use a LOCAL path to sh.exe (the one from Git install)

The expected result is to run an Alpine container and execute the command /bin/sh -c "echo AAA" inside the container

like image 639
Sac Valley Tech Avatar asked Oct 23 '25 17:10

Sac Valley Tech


1 Answers

In the version of bash used in Git for Windows, paths using / are rewritten into Windows paths. This is because many Windows programs don't handle Unix-style paths and this makes more programs work properly.

However, in your case, this results in /bin/sh being rewritten into the path to the Windows executable, which obviously you don't want if you're passing it into a Linux Docker container. The solution to this is to double the slashes (or at least the initial slash), which will tell the shell not to rewrite it.

like image 182
bk2204 Avatar answered Oct 26 '25 07:10

bk2204



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!