我正在尝试使用以下Dockerfile为我的API构建Docker映像:
FROM microsoft/dotnet AS build-env
ARG source
RUN echo "source: $source"
WORKDIR /app
RUN apt-get update
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash
RUN apt-get install nodejs
RUN node -v
RUN npm -v
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
#Copy everything else & build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM microsoft/dotnet
WORKDIR /app
COPY --from=build-env /app/out .
EXPOSE 80
ENTRYPOINT ["dotnet", "API_App.dll"]
但是,当我运行docker build命令时,我不断收到以下错误:
Unable to locate package nodejs
The command '/bin/sh -c apt-get install nodejs returned a non-zero code: 100
有人可以告诉我为什么会出现此错误吗?
节点版本:8.11.3
npm版本:5.6.0
答案 0 :(得分:0)
当您从中提取数据的实时存储库发生更改时,您有时可能会遇到一些缓存问题。
要解决此问题,请在安装任何新软件包之前修改Dockerfile进行清理和更新源。
...
# clean and update sources
RUN apt-get clean && apt-get update
...
此答案来自Control.Invoke