Search code examples
gitdockerpathgit-bashdocker-cli

Docker command not working in Git Bash on Windows (exec: "com.docker.cli": executable file not found in %PATH%)


I have Docker Desktop for Windows and Git (including Git Bash) installed on my computer. The docker command works in the Command Prompt and in Powershell, but not in Git Bash. When I run the docker command in Git Bash, I get the following error.

exec: "com.docker.cli": executable file not found in %PATH%
Current PATH : ...;C:\Program Files\Docker\Docker\resources\bin;D:\Program Files\Git\cmd;C:\ProgramData\DockerDesktop\version-bin;...

I need to get Docker to work via Git Bash to run .sh files containing docker commands with Git Bash. I can't find any reason for this error to occur.

... are other paths which are in PATH, but which are not connected to Git Bash or Docker


Solution

  • I encountered similar situation, where docker tools were in the used path but for some reason calling docker ended up with the same error message.

    The solution in our case was to move the docker path higher in the list in System Properties -> Advanced -> Environment Variables -> System Variables -> Path -> Edit...

    I assume that the problem was that in this case path was so long, that it got cut when delivered to the called process and in this process, end of the path was lost so tooling couldn't find the com.docker.cli anymore in the path. And moving docker path higher in the list makes it appear earlier in the path -variable. However, the path needs to be really long, with the length of the $PATH of 1200 characters, it works just fine, but problematic length in this case was around 2500 characters.