简体   繁体   中英

"The system cannot find the file specified." when running ECS Fargate task

I am trying to run a Fargate (Windows) task on AWS ECS but it fails as soon as it ends it's "PENDING" state. I am not sure what I am missing. There is only 1 possible file that could cause this - Wait-Service.ps1 but I don't see why it shouldn't be found.

The Wait-Service.ps1 file is located in bin/Debug folder.

This is my Dockerfile :

# escape=\

FROM mcr.microsoft.com/windows/servercore:ltsc2019

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

RUN "mkdir C:\temp"

WORKDIR "C:/service"

COPY bin/Debug/ .

RUN "C:/Windows/Microsoft.NET/Framework64/v4.0.30319/installutil.exe" /LogToConsole=true /ShowCallStack ./SprProductionDataService.exe; \
  Set-Service -Name "\"SprProductionDataService\"" -StartupType Automatic; 

#The container stays up as long as this process is running.
CMD "C:/service/Wait-Service.ps1" -ServiceName "SprProductionDataService" -StartupTimeout 10 -AllowServiceRestart;

I only see this error message (in the AWS Console):

Status reason   CannotStartContainerError: CannotStartContainerError: 
hcs::System::CreateProcess 5d85964e54844ae0ad18140057019deb-4109322994: 
The system cannot find the file specified.: unknown

UPDATE :

I tried to run the container pulling it from the ECR repo and it does fail as well:

PS D:\_Code\SPRProductionDataService\SprProductionDataService> docker run --name sprprod -it spr-production-service-dev-ecr:latest 208555724522.dkr.ecr.us-west-2.amazonaws.com/spr-production-service-dev-ecr:latest powershell
docker: Error response from daemon: container e1658203aca736881659e1a5445e8d0ec549ccf94fe2f2952012752e330d9826 encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF7FACA9F4B: (caller: 00007FF7FAC5E13A) Exception(2) tid(3a4) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
 Provider: 00000000-0000-0000-0000-000000000000].

After digging a bit more, I found out that I missed to specify the ENTRYPOINT of the container which in my case is powershell . The bellow dockerfile worked for me:

# escape=\

FROM mcr.microsoft.com/windows/servercore:ltsc2019

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

RUN "mkdir C:\temp"

WORKDIR "C:/service"

COPY bin/Debug/ .

# For debugging purposes only
#RUN Enable-WindowsOptionalFeature -Online -FeatureName "TelnetClient"

RUN "C:/Windows/Microsoft.NET/Framework64/v4.0.30319/installutil.exe" /LogToConsole=true /ShowCallStack ./SprProductionDataService.exe; \
  Set-Service -Name "SprProductionDataService" -StartupType Automatic; 

#The container stays up as long as this process is running.
ENTRYPOINT ["powershell.exe"]
CMD ["C:/service/Wait-Service.ps1", "-ServiceName", "SprProductionDataService", "-StartupTimeout", "10", "-AllowServiceRestart"];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM