简体   繁体   English

如何使用 Windows 容器 dotnet/aspnet:6.0 在 Docker 中安装 Node JS?

[英]How to install Node JS in Docker with a Windows Container dotnet/aspnet:6.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.看起来应该相当简单,但由于 windows 容器正在使用 nano 并且没有 msiexec.exe 来安装软件包,因此在谷歌搜索几个小时后我没有找到一个完善的替代方案。 So, how would one best do the below in a nano based windows container?那么,如何在基于纳米的 windows 容器中最好地执行以下操作?

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 Windows Docker 容器
  • dockerfile VS makes, which has a base of dotnet/aspnet:6.0 and uses dotnet/sdk:6.0 in the build stage dockerfile VS make,它的基础是dotnet/aspnet:6.0,在构建阶段使用dotnet/sdk:6.0

Base stage of dockerfile where I want to do my install of node at: dockerfile 的基础阶段,我想在其中安装节点:

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.对于它的价值,我习惯了基于 Linux 的容器,这是我第一次尝试使用 Windows 的容器。 Please correct me on anything I may have misspoken on or misrepresented.请纠正我可能说错或歪曲的任何内容。

Welcome to the Windows world: :)欢迎来到 Windows 世界::)

On Windows, .Net has two flavors: .Net and.Net Framework.在 Windows 上,.Net 有两种风格:.Net 和 .Net Framework。 The former (.Net) was previously called.Net Core and since its renaming to.Net it has caused some confusion.前者(.Net)以前被称为.Net Core,自从它重命名为.Net以来,它引起了一些混乱。 To clarify:澄清:

  • .Net Framework is the legacy framework on which.Net was only available in Windows. .Net 框架是 .Net 仅在 Windows 中可用的遗留框架。
  • .Net (formerly called.Net Core) is available on Windows and Linux. .Net(以前称为 .Net Core)在 Windows 和 Linux 上可用。 At first, .Net on Windows was only available on Nano Server base container images.起初,Windows 上的 .Net 仅在 Nano Server 基础容器镜像上可用。 However, recently the team made it available on the Server Core image, which supports a wider range of pre-requisites, such as MSIEXEC.但是,最近该团队在 Server Core 映像上提供了它,该映像支持更广泛的先决条件,例如 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我对您的建议是查看您要在此处使用的图像的可用标签列表: https://mcr.microsoft.com/en-us/product/dotnet/aspnet/tags

Also, look at the documentation of Windows containers.另外,请查看 Windows 容器的文档。 There's a particularity of Windows containers which is a version match requirement between container host and container. Windows 容器有一个特殊性,这是容器主机和容器之间的版本匹配要求。 More details here: https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility?tabs=windows-server-2022%2Cwindows-11-21H2更多详细信息: https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility?tabs=windows-server-2022%2Cwindows-11-21H2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM