【发布时间】:2022-02-11 00:15:30
【问题描述】:
我尝试从 Dockerfile 构建映像,但收到此错误:
/bin/sh: 1: -E: not found
The command '/bin/sh -c curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | -E bash -' returned a non-zero code: 127.
我的 Dockerfile 是:
ARG NODE_VERSION
ARG ANGULAR_VERSION
WORKDIR /
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get install bash -y
RUN apt-get install curl -y
RUN curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | -E bash -
RUN apt-get install nodejs
RUN npm install @angular/cli@$ANGULAR_VERSION
RUN mkdir dpa-frontend
ADD --chmod=777 /home/dockerCoach/dap-frontend/* /dpa-frontend
WORKDIR /dpa-frontend
RUN npm install
RUN ng build --configuration=production
FROM ubuntu:latest AS deploy
ARG NODE_VERSION
WORKDIR /
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get install bash -y
RUN apt-get install curl -y
RUN install curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | -E bash -
RUN npm install nodejs
RUN npm install -g pm2 &\
pm2 update
WORKDIR /dap-frontend
COPY --from=build /dpa-frontend/dist .
EXPOSE 4000
CMD pm2 start "ng serve --host 0.0.0.0 --port 4000" --name "dpa-frontend"
【问题讨论】:
-
在构建时是否传递了
NODE_VERSION和ANGULAR_VERSION的构建参数?有什么理由不从官方的 nodejs 图像之一开始作为您的基础?