1

I am trying to build a Docker image for my API with the following Dockerfile:

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"]

However, when I run the docker build command, I keep getting the following error:

Unable to locate package nodejs
The command '/bin/sh -c apt-get install nodejs returned a non-zero code: 100

Can someone tell me why I am getting this error?

Node Version: 8.11.3 npm Version: 5.6.0

SamRR_75
  • 729
  • 8
  • 18

1 Answers1

4

You may occasionally experience some cache issues when the live repositories you’re pulling data from have changed.

To fix this, modify the Dockerfile to do a cleanup and update of the sources before you install any new packages.

...
# clean and update sources
RUN apt-get clean && apt-get update
...

This answer is from digitalocean-issue