Docker: command not found

I’m encountering issues while trying to run a script (run.sh) which is supposed to run a Docker image that I’ve already built. I’m trying to do this in GitBash on Windows 10. Despite Docker being installed and accessible from the command line, the script fails with errors such as “docker: command not found”.

I can confirm that when I enter “docker --version”, I get: “Docker version 26.0.0, build 2ae903e”. So I can confirm that Docker is installed. What’s more is I’ve run commands to build my image just a few minutes earlier, and the image appears in the Images section of the Docker Desktop for Windows app.

Docker Desktop is running in WSL 2 mode.

I’ve checked the permissions of the run.sh file, and it has read and execute permissions.

I’ve tried “echo $PATH”, and can confirm that Docker is set up in the environment variables.

Despite taking these steps, the script still fails to execute Docker commands (for example: “docker container rm ${GALAXY_NAME}”), returning “docker: command not found” errors. Other users have successfully run the same script before, suggesting that the issue may be specific to my environment.

I have to admit that I’m new to Docker, but I’ve seemed to have exhausted everything anything suggests. Anyone have any other ideas?

It is not clear to me in your description where you ran the docker --version command. If you did it in Git Bash, and the script also runs using Git Bash, it should work. If not, it could be a GitBash specific issue or something in your script that prevents finding the docker command.

Did you add it to the script before the docker command, or ran it directly from Git Bash?

Thank you for your reply!

  1. Yes, I ran “docker --version” in gitBash, which is where I’m trying to run the script run.sh from.

  2. When I ran “echo $PATH”, it was in GitBash, and shows me that docker was listed. Also for splits and giggles manually checked the Environment Variables in the Windows system settings, and confirmed the Docker bin path is listed.

And I should say this isn’t my script, and seems to be working just fine for hundreds of others.