Home > Net >  "docker build": cannot find 'make' even though already installed
"docker build": cannot find 'make' even though already installed

Time:10-22

I'm trying to create a docker image on MacOS using the below command. Note docker build cannot run any command, I tried it with npm --version, and it couldn't find npm either.

% docker build -<<EOF 
# syntax=docker/dockerfile:1
FROM ubuntu:20.04
COPY . /app
RUN make /app
CMD node /app/index.js
EOF

Here's the error message I'm getting:

[output clipped...]
=> ERROR [3/3] RUN make /app                                                                                                
------
> [3/3] RUN make /app:
#11 0.200 /bin/sh: 1: make: not found
------
executor failed running [/bin/sh -c make /app]: exit code: 127

However, make is already installed, via xcode-select:

% /bin/sh -c make /app
make: *** No targets specified and no makefile found.  Stop.

Can anyone help me here please? Thanks!

CodePudding user response:

Docker can't use software installed on the host. You need to install make in your Dockerfile like this

% docker build -<<EOF 
# syntax=docker/dockerfile:1
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y build-essential
COPY . /app
RUN make /app
CMD node /app/index.js
EOF
  • Related