angular – How can we run NodeJs in Docker (Windows 10) for ASP.NET Core applications? – Stack Overflow


I have created an angular application on a windows machine using the following code.

dotnet new angular

Next I saw that there is an option to add Docker support from within Visual Studio .NET, so I installed that using the option.

Here is the file that is produced.

FROM AS base

FROM AS build
COPY ["MOCK3/PBS.Mock3.csproj", "MOCK3/PBS.Mock3/"]
RUN dotnet restore "MOCK3/PBS.Mock3.csproj"
COPY . .
WORKDIR "/src/MOCK3/PBS.Mock3"
RUN dotnet build "PBS.Mock3.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "PBS.Mock3.csproj" -c Release -o /app/publish

FROM base AS final
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "PBS.Mock3.dll"]

Unfortunately, the application cannot find npm installed on the docker instance when it is run and produces the following error.

The error output was: 'npm' is not recognized as an internal or external command,

After researching, I found examples of how to run and install npm in the docker file but this doesn’t work so I assume that it is for Linux users. Those posts generally have the following (which as mentioned does not work on my machine).

RUN apt-get update -yq \
   && apt-get install curl gnupg -yq \
   && curl -sL | bash \
   && apt-get install nodejs -yq

This doesn’t work as advertised and there is no mention of environment in which it should work. Before, I go and start installing unneeded windows cli applications which is the tried and true Windows approach that I have been unable to find anywhere?


The Docker Images comes with the simplest environment inside the containers. You can use Node Image(, that contains only the node installed. Or the aspnet, containing only aspnet instead. But to a combined scenario you need to install one or another.

In docker, you can install some image based on Linux distribution like Debian or alpine, which is very small and light. You can find a lot of examples.

You can try to install the node with powershell commands. I don’t know an specific script to get and install the node, but you can research or use some examples, like this one (

You can also try to “merge” two containers. ( In fact, what it says is to generate the history and reproduce the command stack.

I think the best option is to use a specific distribution tag image. I recommend alpine.