Docker Community Forums

Share and learn in the Docker community.

/bin/sh: git: not found

I’m getting the error “/bin/sh: git: not found” when running ‘docker build’.

My bash shell knows where git is:

which git

Also /usr/local/bin is the first item in my $PATH. But /bin/sh can’t find git.

How can I tell /bin/sh where git is located?

Edited to add:
Using macOS 10.14.6 (Mojave), Docker version 20.10.2, build 2291f61

I found the answer to my own question. My Dockerfile specified to use the Alpine Linux OS, which is a minimal OS:
FROM node:current-alpine3.10

So it didn’t have git installed by default. By adding this line before the line containing “RUN git clone” it installed git in the container (apk is the package manager for Alpine Linux):

RUN apk update && apk add git

Looks like you’re missing git. Install Xcode from the app store. It comes with git. If you are a homebrew user, and want the latest version (which I would consider optional in your case), you can install it with brew update; brew install git.

I already have git on my Mac. But git was not installed in the container until I added the new line telling it to install git.