Skip to content

ECS Fargate Task Fails with Windows 2022 Core OS - Container OS Mismatch and Troubleshooting Guidance Required

0

I am trying to deploy a .NET Framework 4.8 application on AWS ECS Fargate using the Windows Server 2022 Core OS. The container image builds and uploads successfully to Amazon ECR; however, the ECS task fails to start. Below is the problem I am encountering:

  1. The task remains stuck in "CREATE_IN_PROGRESS" state and eventually fails.
  2. I receive the following error message in the ECS service events: `
CannotStartContainerError: ResourceInitializationError: failed to create new container runtime task: 
hcs::CreateComputeSystem failed: The container operating system does not match the host operating system. (0xc0370101)

` 3. I confirmed that the container is built using the following base images:

mcr.microsoft.com/dotnet/framework/runtime:4.8 (Used to run the .NET application in production) mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022 (Used for building the application during the Docker build process)

  1. The same image fails locally on my Windows 11 Pro machine (OS Build: 22621.4317) with similar errors. Specifically, the Docker error shows: The container operating system does not match the host operating system. (0xc0370101)

What I Have Tried So Far: 1. Verified Platform Versions:

Ensured the ECS task definition specifies Windows Server 2022 Core compatibility.

"runtimePlatform": {
  "operatingSystemFamily": "WINDOWS_SERVER_2022"
}

2. Confirmed IAM and Logging Setup:

  • Enabled CloudWatch logging in the ECS task definition to capture any runtime logs.
  • Set up IAM permissions to allow ECS tasks to write logs to CloudWatch, but the logs are not showing any detailed errors.

3. Rebuilt the Docker Image:

  • Successfully built the image locally using the following command:
docker build -t s3-uploader-app:latest .
  • Tested the image with:
docker run --rm --isolation=process s3-uploader-app:latest

This gave the same OS mismatch error both locally and on ECS.

4. Restarted Docker Desktop and Pruned All Images:

  • Reinstalled Docker Desktop and ensured **Windows Containers **are enabled.
  • Ran the following commands:
docker pull mcr.microsoft.com/windows/servercore:ltsc2022
docker run --rm mcr.microsoft.com/windows/servercore:ltsc2022 cmd /c echo "Hello from Windows"
  • The container runs correctly using the above command, confirming Docker is operational.

Environment Details:

Local Machine:

  • OS: Windows 11 Pro, Version: 22H2, Build: 22621.4317
  • Docker Desktop: Enabled for Windows containers
  • Docker version: Latest

AWS ECS Configuration:

  • Launch Type: Fargate
  • Cluster: rrt-app-sandbox-ue1-ecs-cluster
  • Task Definition: Set to Windows Server 2022 Core
  • Image: Hosted in Amazon ECR with the latest tag

Request for Guidance:

  • Is there anything specific I need to check to ensure the Windows 2022 OS compatibility on ECS Fargate?
  • Are there any known issues with Docker images built using* mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022*?
  • How can I increase the ECS task logging verbosity to gain better insights into the task failures?

Any suggestions, troubleshooting steps, or pointers would be highly appreciated!

  • Can you supply the docker file?

2 Answers
0

Based on the information provided, it appears you're encountering a container operating system mismatch issue when trying to run your .NET Framework 4.8 application on AWS ECS Fargate using Windows Server 2022 Core. This is a common issue when the container OS doesn't align with the host OS. Here are some suggestions to troubleshoot and potentially resolve the issue:

  1. Verify Fargate Platform Version: Ensure you're using the latest Fargate platform version that supports Windows Server 2022. Check your task definition to confirm it specifies the correct operating system family.

  2. Image Compatibility: The base images you're using (mcr.microsoft.com/dotnet/framework/runtime:4.8 and mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022) should be compatible with Windows Server 2022 Core. However, ensure that all layers in your Dockerfile are using Windows Server 2022 compatible images.

  3. Task Definition Review: Double-check your task definition to ensure it's correctly configured for Windows Server 2022. The "runtimePlatform" section should specify "WINDOWS_SERVER_2022" as the operating system family.

  4. Increase Logging Verbosity: To gain more insights into the task failures, you can increase the logging verbosity in your task definition. Add the following to your task definition:

"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/your-task-definition-name",
"awslogs-region": "your-region",
"awslogs-stream-prefix": "ecs",
"awslogs-create-group": "true"
}
}

This will send more detailed logs to CloudWatch, which may provide additional information about the failure.

  1. Check ECS Agent Logs: If possible, try to access the ECS agent logs on the Fargate instance. These logs might contain more detailed information about why the task is failing to start.

  2. Verify Image Pull: Ensure that Fargate can successfully pull your image from ECR. Check that your task execution role has the necessary permissions to pull images from ECR.

  3. Simplify Your Container: As a troubleshooting step, try creating a simple Windows Server 2022 Core container without your application code. If this works, gradually add components back until you identify the problematic part.

  4. Local Testing: Since you're experiencing similar issues locally, focus on resolving the problem on your local machine first. Ensure your local Docker is set up correctly for Windows containers and that you're using the latest version of Docker Desktop.

  5. Consider Fargate Spot: If you're not already using it, consider trying Fargate Spot. Sometimes, issues that occur on regular Fargate instances might not appear on Spot instances due to differences in the underlying infrastructure.

  6. AWS Support: If the issue persists after trying these steps, consider reaching out to AWS Support. They can provide more specific guidance based on your account and configuration.

Remember, when working with Windows containers, ensuring version compatibility between the base image, your application, and the host OS is crucial. Continue to monitor the ECS service events and CloudWatch logs for any additional error messages that might provide more clues to resolve the issue.
Sources
Troubleshoot metadata errors in my ECS Fargate tasks | AWS re:Post
Troubleshooting Amazon ECS TaskFailedToStart errors - Amazon Elastic Container Service
Windows Containers on AWS Fargate: Launch time improvements | Containers
Serverless Compute Engine – AWS Fargate Features – Amazon Web Services

answered 2 years ago

0

WINDOWS_SERVER_2022 is an invalid operating system type.

Please see the options.

operatingSystemFamily The operating system.

Type: String

The valid values for Amazon ECS tasks that are hosted on Fargate are LINUX, WINDOWS_SERVER_2019_FULL, WINDOWS_SERVER_2019_CORE, WINDOWS_SERVER_2022_FULL, and WINDOWS_SERVER_2022_CORE.

The valid values for Amazon ECS tasks hosted on EC2 are LINUX, WINDOWS_SERVER_2022_CORE, WINDOWS_SERVER_2022_FULL, WINDOWS_SERVER_2019_FULL, and WINDOWS_SERVER_2019_CORE, WINDOWS_SERVER_2016_FULL, WINDOWS_SERVER_2004_CORE, and WINDOWS_SERVER_20H2_CORE.

EXPERT

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.