Git Bash is an awesome shell that comes with Git for Windows but Docker and Docker Compose don't work well in it due to path conversions, see e.g. this issue. Same with MSYS2 shells.
To confirm that you have the problem, run this:
$ docker run --rm -it ubuntu /bin/bash
If you get this error, you're impacted:
stat C:/Program Files/Git/usr/bin/bash: no such file or directory
Note how the Linux path is prepended with C:/Program Files/Git which is of course completely wrong from the container's point of view. Another common example is volume mapping, e.g.:
docker run -v "$PWD":/var/www/html php:7-apache
This commonly fails as well.
The key to a solution is to set either the MSYS_NO_PATHCONV variable for Git Bash shell, or MSYS2_ARG_CONV_EXCL for MSYS shells.
Create two small scripts, docker and docker-compose (no extension) in some location that has higher-priority than Docker's path. Docker is quite aggressive and puts itself very high in the list, the safest way is to become no. 1 system path (not user path) to beat it. Here is an example from my computer:
The contents of the docker proxy script should look like this:
#!/bin/bash
if [[ -v MSYS2_PATH_TYPE ]]; then
# !!! Until https://github.com/Alexpux/MSYS2-packages/issues/411 is resolved,
# !!! make sure you use winpty binaries from https://github.com/rprichard/winpty/releases
# !!! *not* from `pacman -S winpty`.
(export MSYS2_ARG_CONV_EXCL="*"; winpty "docker.exe" "$@")
else
(export MSYS_NO_PATHCONV=1; "docker.exe" "$@")
fiSimilarly for docker-compose.
Hope this helps.


What extention did you use for your script? I tried using .SH and adding .SH to my PATHEXT, but it still prioritizes Docker.exe unless i type docker.sh