我的应用程序上有Makefiles,我在Makefiles上的所有命令都放在Dockerfile上:
# start from the latest golang base image
FROM golang:alpine
RUN apk update && apk add --no-cache gcc && apk add --no-cache libc-dev
# Set the current working Directory inside the container
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download all dependencies. they will be cached of the go.mod and go.sum files are not changed
RUN go mod download
# Copy the source from the current directory to the WORKDIR inisde the container
COPY . .
# Build the Go app
RUN go build .
# Exporse port 3000 or 8000 to the outisde world
EXPOSE 3000
# Command to run the executable
CMD ["make", "-C", "scripts", "test" ]
CMD ["make", "-C", "scripts", "prod" ]
字符串
并得到
docker: Error response from daemon: OCI runtime create failed:
container_linux.go:349: starting container process caused "exec:
\"make\": executable file not found in $PATH": unknown.
型
在Docker中可以运行make -c scripts test
吗?如何在Docker中正确使用此命令?
在dockerfile
中运行golang:alpine
3条答案
按热度按时间dxpyg8gm1#
如果您添加了
RUN apk add --no-cache make
,但仍然存在问题,请将以下内容也添加到您的DockerFile:字符串
Alpine图像是轻量级的,没有实用程序,添加g++解决了这个问题。
参考号:https://mroldan.medium.com/alpine-sh-make-not-found-1e87ab87c56
gv8xihay2#
这里有两件事我会在Dockerfile中修复:
apk add make
字符串
kjthegm63#
如果您希望避免将make的所有依赖项添加到您的alpine映像中,并保持运输容器的大小较小: