Docker Community Forums

Share and learn in the Docker community.

Trouble installing node js onto mcr.microsoft.com/dotnet/core/sdk:2.2

Hi,

Im trying to install node into my container.

If i do this it FAILS:

FROM mcr.microsoft.com/dotnet/core/sdk:2.2
# Setup NodeJs
RUN apt-get update -y
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash --debug
Run apt-get install nodejs -yq
# End setup

the error Produced is :

 apt-get install -y apt-transport-https lsb-release > /dev/null 2>&1
Error executing command, exiting

BUT If i do this it SUCCEEDS:

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim
# Setup NodeJs
RUN apt-get update -y
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash --debug
Run apt-get install nodejs -yq
# End setup

Obviously the first is using the SDK… but i was under the impression the SDK contained everything the runtime does plus the development tools?

I’m thinking this may be a bug with the official SDK image?

Any help would be greatly appreciated. Thanks

We used this block of code in Dockerfile to pull Node in to our aspnet core 2.2 base image microsoft/dotnet:2.2-aspnetcore-runtime-nanoserver-sac2016

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ENV NODE_VERSION 8.11.3
ENV NODE_FULL_NAME node-v8.11.3-win-x64

#install node and npm as MS no longer does this in any .NET Core nanoserver based images since 2.1
RUN New-Item -ItemType directory -Path /build; \
    Invoke-WebRequest https://nodejs.org/dist/v${env:NODE_VERSION}/${env:NODE_FULL_NAME}.zip -OutFile /build/${env:NODE_FULL_NAME}.zip; \
    Expand-Archive -LiteralPath /build/${env:NODE_FULL_NAME}.zip /build; \
    $newPath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path; \
    $nodeFullName = ${env:NODE_FULL_NAME}; \
    $newPath = $newPath + ';/build/' + $nodeFullName; \
    Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath;

Hi,

Thanks for the reply.

It works with the runtime but i want to install into the sdk so i can make a build layer? also i’m using Linux containers, sorry should have mentioned that.

Just found it works on my laptop but not on my home computer? both running windows 10… am i missing something or this not meant to happen lol