skip to Main Content

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:_CodeSPRProductionDataServiceSprProductionDataService> 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: onecorevmcomputemanagementorchestrationvmhostedcontainerprocessmanagement.cpp(173)vmcomputeagent.exe!00007FF7FACA9F4B: (caller: 00007FF7FAC5E13A) Exception(2) tid(3a4) 80070002 The system cannot find the file specified.
    CallContext:[Bridge_ProcessMessageVmHostedContainer_ExecuteProcess]
 Provider: 00000000-0000-0000-0000-000000000000].

2

Answers


  1. Chosen as BEST ANSWER

    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"];
    

  2. The Problem here is the way ENTRYPOINT/CMD was specified.

    In first Dockerfile you had specified CMD in shell form.
    In Second Dockerfile you had specified ENTRYPOINT and CMD in exec form. refer – This

    Basically, ECS Fargate runs containerd runtime and this runtime is not good while handling the shell form.

    There is an open github issue which describes the behavior.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search