Remediation
Update the ECS Task Definition to Run Containers as a Non-Root Userβ
Using the AWS CLIβ
-
Retrieve the existing task definition JSON
aws ecs describe-task-definition \
--task-definition {{family-or-full-arn}} \
--query 'taskDefinition' > task-def.json -
Edit
task-def.jsonIn the
containerDefinitionsarray, update each container to run as a non-root user by setting theuserparameter to a non-zero UID."containerDefinitions": [
{
"name": "{{my-app}}",
"image": "{{my-image}}",
"user": "{{1000}}",
...
}
] -
Register the updated task definition
aws ecs register-task-definition --cli-input-json file://task-def.json -
Update your ECS service to use the new task definition revision