0

Seems like something that should be fairly simple, but since windows containers are using nano and don't have msiexec.exe to install packages with I'm not finding a well established alternative after googling for several hours now. So, how would one best do the below in a nano based windows container?

RUN msiexec.exe /i https://nodejs.org/dist/v18.7.0/node-v18.7.0-x64.msi /quiet

What I'm using:

  • Windows Docker Containers
  • dockerfile VS makes, which has a base of dotnet/aspnet:6.0 and uses dotnet/sdk:6.0 in the build stage

Base stage of dockerfile where I want to do my install of node at:

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
# install node for npm usage
RUN msiexec.exe /i https://nodejs.org/dist/v18.7.0/node-v18.7.0-x64.msi /quiet

For what it's worth, I'm use to Linux based containers and this is the first time I've tried out using Windows ones. Please correct me on anything I may have misspoken on or misrepresented.

CoderLee
  • 3,079
  • 3
  • 25
  • 57

1 Answers1

0

Welcome to the Windows world! :)

On Windows, .Net has two flavors: .Net and .Net Framework. The former (.Net) was previously called .Net Core and since its renaming to .Net it has caused some confusion. To clarify:

  • .Net Framework is the legacy framework on which .Net was only available in Windows.
  • .Net (formerly called .Net Core) is available on Windows and Linux. At first, .Net on Windows was only available on Nano Server base container images. However, recently the team made it available on the Server Core image, which supports a wider range of pre-requisites, such as MSIEXEC.

My suggestion to you is to look at the list of available tags for the image you want to use here: https://mcr.microsoft.com/en-us/product/dotnet/aspnet/tags

Also, look at the documentation of Windows containers. There's a particularity of Windows containers which is a version match requirement between container host and container. More details here: https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility?tabs=windows-server-2022%2Cwindows-11-21H2

  • 1
    Are you suggesting there isn't a way to install packages on nano server? I wanted to take advantage of its smaller footprint which is why I didn't opt for Server Core yet. – CoderLee Aug 18 '22 at 22:06
  • No, what I'm saying is Nano Server does not support MSIEXEC. If you have a .Net app (for example) you can install dependencies just like you would on any Dotnet restore. If you need MSIEXEC, then Server Core is the image that supports that. – Vinicius Apolinario Aug 22 '22 at 16:03
  • 1
    Ok, right, that was my point...so how does one install something on nano server? I don't want to use server core and nuget deps has nothing to do with installing Node or other executables. – CoderLee Aug 24 '22 at 04:27
  • 3
    @ViniciusApolinario how does this answer the question? A random high level explanation of .NET Framework vs Core vs Unified and suggesting CoderLee doesn't use nano server makes no sense as an answer, unless I'm missing something? – recursivePython Aug 24 '22 at 04:36
  • So, first of all, I was simply trying to explain the nuances of Windows and .Net since @CoderLee mentioned they were new to Windows. My apologies is that caused more confusion. As for the question on how to deploy something on Nano Server, this needs to be something that does not require an API that is not there. MSIEXEC is not there, so the logic answer here is: You need the Server Core image in this case. I'm not a NPM expert, but in this case I would ask the NPM community for an alternative to install NPM which does not require MSIEXEC. – Vinicius Apolinario Aug 24 '22 at 23:10
  • I guess I needed to clarify, new to windows containers. I’ve been using .NET since framework 3.5. So @ViniciusApolinario you’re saying you don’t know how to install an exe on nano server, right? – CoderLee Aug 26 '22 at 00:10
  • It’s ok that you don’t understand how this works, but you’re not answering my question by suggesting I use server core instead of nano. That’s only the answer if it’s impossible to install anything on nano server. So, are you suggesting that’s the case? – CoderLee Aug 26 '22 at 00:13
  • My sincere apologies for the confusion here. What I'm saying is that if you tried to install something on a Nano Server image the conventional way as you would on any other Windows instance (VM or not) and it did not work, than it's because the API/component that performed that action was removed from the image. Essentially, there's no way to install this on Nano Server - the Server Core is the image for you. – Vinicius Apolinario Aug 29 '22 at 22:24
  • I was looking into this bit more and noticed that Node.JS has a zip download option that includes Node and NPM. Have you tried this option instead of the MSI installer? – Vinicius Apolinario Aug 29 '22 at 22:39
  • I went back to your comments once again to see if I was missing something. I guess one clarification is needed: MSIEXEC is not present on Nano Server images. What that means is that the framework you want to install needs to provide a way to get it installed on Nano Server. With that said, I also went to look into how the .Net team built their images on Nano Server: https://github.com/dotnet/dotnet-docker/blob/18ede68e65c2571914adad08484f230204292a83/src/aspnet/6.0/nanoserver-ltsc2022/amd64/Dockerfile – Vinicius Apolinario Aug 30 '22 at 20:51
  • Basically, they use the Server Core image as a build stage and then copy the artifacts (binaries) to the Nano Server image. You might be able to leverage something similar to get NPM/Node.JS on Nano Server. Now, my final point here is that since this is a foreign application to Windows, the application owner needs to provide a way for it to be installed on the Windows platform. As far as I know they provide a MSI file and the binaries. You might want to reach out to the Node community to check if someone has hacked on this and maybe has an image with Nano Server? – Vinicius Apolinario Aug 30 '22 at 20:51