我正在尝试构建一个Windows docker镜像,该镜像将复制我的软件并解压缩它。 我在Windows 10主机上工作。 步骤如下:
Prepare file Dockerfile. with the following lines:
FROM mcr.microsoft.com/windows/servercore:ltsc2019
COPY image.zip c:\image.zip
CMD ["powershell.exe", "Expand-Archive -LiteralPath 'C:\image.zip' -DestinationPath 'c:\'"
Prepare a zip file called image.zip with some files.
Run command:
docker build -t test3 .
At this point the image is built. image.zip was copied to the image.
Run the container:
docker run --rm -it test3 powershell
From the container powershell run:
dir
目前,我期望在构建过程中已解压缩的“image.zip”文件的内容会被显示出来。但实际上并没有,只有一个“image.zip”文件。
docker run
命令行中提供的命令将代替镜像的CMD
。您是想要运行该命令以提取归档文件吗? - David MazeRUN
在构建镜像时运行;CMD
指定容器启动时应运行的命令。请参阅Dockerfile 中 RUN 和 CMD 的区别。 - David Maze