node.js - Win10 Professional Dockerizing Augular App 给出:未知指令:EXPAND-ARCHIVE
问题描述
我要为其他 Windows 机器创建一个 Angular Web 应用程序的 docker 映像。当涉及到命令执行时:
docker build -t node .
它给出了以下例外:
Error response from daemon: Dockerfile parse error line 10: unknown instruction: EXPAND-ARCHIVE
请告诉我如何更正第 10 行以便提取 zip 文件?
这是我的 Dockerfile
FROM mcr.microsoft.com/windows/servercore:1803 as installer
ENV NPM_CONFIG_LOGLEVEL info
ENV NODE_VERSION 8.11.0
ENV NODE_SHA256 7b2409605c871a40d60c187bd24f6f6ddf10590df060b7d905ef46b3b3aa7f81
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';$ProgressPreference='silentlyContinue';"]
RUN Invoke-WebRequest -OutFile nodejs.zip -UseBasicParsing "https://nodejs.org/dist/v8.11.0/node-v8.11.0-win-x64.zip";
Expand-Archive nodejs.zip -DestinationPath C:\;
Rename-Item "C:\\node-v8.11.0-win-x64" c:\nodejs
FROM mcr.microsoft.com/windows/nanoserver:1803
WORKDIR C:\nodejs
COPY --from=installer C:\nodejs\ .
RUN SETX PATH C:\nodejs
RUN npm config set registry https://registry.npmjs.org/
WORKDIR /app
# install and cache app dependencies
COPY src/WebSpa/package.json /app/src/WebSpa/package.json
WORKDIR /app/src/WebSpa
RUN npm install
RUN npm install -g @angular/cli@latest
# add app
COPY . /app
# start app
CMD cd /app/src/WebSpa && ng serve --host 0.0.0.0
解决方案
您的 Dockerfile RUN 命令中有一行返回,导致它不链接 powershell 命令,而是尝试将第二个命令作为 Docker 命令执行。
它应该如下所示:
RUN Invoke-WebRequest -OutFile nodejs.zip -UseBasicParsing "https://nodejs.org/dist/v8.11.0/node-v8.11.0-win-x64.zip"; Expand-Archive nodejs.zip -DestinationPath C:\; Rename-Item "C:\\node-v8.11.0-win-x64" c:\nodejs
推荐阅读
- javascript - 打字稿:有条件地将对象属性标记为可选?
- java - 如何用 Jackson 序列化扩展 TreeSet 的类?
- mysql - 使用单个查询获取列中每个值的顶级类别
- r - 复制蒙蒂大厅游戏
- linux - Cgroup 意外地将 SIGSTOP 传播到父级
- lua - 如何将数据和表插入现有的?
- android - 你可以直接在android应用程序中链接静态库吗?
- php - mPDF - 用于生成 PDF 文件的 html 代码块内的 PHP 脚本
- docker - 如何在 Docker 中为 Java 11 设置内存限制?
- c# - QueueTrigger 函数能否作为控制器进行响应