I am trying to build a nanoserver image which includes task scheduling in the dockerfile:
FROM mcr.microsoft.com/windows/nanoserver:20H2
USER ContainerAdministrator
RUN schtasks /create /tn test /tr test /sc weekly /d MON /st 00:00 /ru system
ENTRYPOINT cmd
When I try to build the image, I get the following result:
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM mcr.microsoft.com/windows/nanoserver:20H2
---> 32f64a4e8b69
Step 2/4 : USER ContainerAdministrator
---> Running in 63300b150890
Removing intermediate container 63300b150890
---> 347e5db0e75e
Step 3/4 : RUN schtasks /create /tn test /tr test /sc weekly /d MON /st 00:00 /ru system
---> Running in 0de9e3866ffb
ERROR: Class not registered
The command 'cmd /S /C schtasks /create /tn test /tr test /sc weekly /d MON /st 00:00 /ru system' returned a non-zero code: 1
However, when I run the same schtasks
command in a container using the same nanoserver image it succeeds.
Does anyone know why the command fails in dockerfile but works in the container command line? Does anyone have a solution to that problem?
Thanks you in advance