首页 > 解决方案 > 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

标签: node.jsangularwindowsdocker

解决方案


您的 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

推荐阅读