/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
/usr/local/bin/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

1 Like