Home > Net >  Run Makefile target inside of docker
Run Makefile target inside of docker

Time:12-04

I am having trouble running make targets inside of Dockerfile. I am also not sure if I should be using bash or alpine as a base of my image.

Makefile:

all:
    echo "all target is working"

test:
    echo "test target is working"

build:
    echo "build target is working"

Dockerfile:

FROM bash:latest

WORKDIR /usr/src/program

COPY Makefile Makefile

Testing:

docker build . -t program
docker run program "make test"

Error:

/usr/local/bin/docker-entrypoint.sh: line 11: exec: more Makefile: not found

CodePudding user response:

The quotes are wrong. You want simply

docker run program make test

Which base image to use depends entirely on what the Makefile tries to do. Unless you are specifically trying to do something specific to Bash, probably the base alpine image is a good starting point.

  • Related