I am trying to build a Windows docker image which will copy my software to the image and unzip it. I am working on Windows 10 host. The steps are:
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
At this point, I expect to see the content of "image.zip" which has been extracted during the build. But I don't, there is just "image.zip".
docker run
command line runs instead of the image'sCMD
. Do you mean toRUN
the command to extract the archive? – PartidaRUN
does run as part of the build;CMD
specifies the command that should be run when the container is started. See also Difference between RUN and CMD in a Dockerfile. – Partida