Hello,
I use Docker Desktop on Windows 10 with Windows containers.
I need to produce a Docker image with Windows nano server 2019 but during the build process I need to run a program in the container with administrative rights (I don’t need administrative rights after the image is created, but just when building).
I can do it manually, it works fine:
- docker run -it --name nano mcr.microsoft.com/windows/nanoserver:20H2 cmd.exe
- exit
- docker stop nano
- docker cp MySetup.exe nano:/MySetup.exe
- docker start nano
- docker exec -it –user “NT Authority\System” nano C:\MySetup.exe
- docker stop nano
- docker commit nano mynanoimage
But I can’t do the same in a dockerfile
FROM mcr.microsoft.com/windows/nanoserver:20H2
COPY MySetup.exe /MySetup.exe
USER "NT Authority\System"
RUN “C:\MySetup.exe”
CMD cmd.exe
Docker build -t mynanoimage2 .
The command ‘cmd /S /C “C:\MySetup.exe”’ returned a non-zero code: 2
I can see in the output that an access was denied, as if USER “NT Authority\System” was ignored.
Am I missing something?
Thank you for your help,
Michel Terrisse