Search code examples
amazon-web-servicesdockerdocker-composeamazon-ecsamazon-ecr

Running a public image from AWS ECR in ECS Cluster


I have successfully pushed my 3 docker images on ECR. Configured an ECS cluster. Created 3 task definitions for those 3 images stored in respective ECR repositories. Now, I want to run a public image of redis on the same cluster as a different task. I tried created a task definition of the same using the following URL: public.ecr.aws/ubuntu/redis:latest

But as soon as I run it as a new task I get the following error:

Essential container in task exited

Any specific reason for this error or am I doing something wrong?


Solution

  • Ok, so the redis image needs to either set a password (I recommend this as well) or allow it to connect to the redis cluster without a password.

    To configure a password or disable passwords auth, you need to set environment variables in the image. You can read the documentation under the heading Configuration

    Luckily, this is easy in ECS. You need to specify the environment variable in the task definition. So either:

    {
        "family": "",
        "containerDefinitions": [
            {
                "name": "",
                "image": "",
                ...
                "environment": [
                    {
                        "name": "ALLOW_EMPTY_PASSWORD",
                        "value": "yes"
                    }
                ],
                ...
            }
        ],
        ...
    }
    

    or for a password:

    {
        "family": "",
        "containerDefinitions": [
            {
                "name": "",
                "image": "",
                ...
                "environment": [
                    {
                        "name": "REDIS_PASSWORD",
                        "value": "your_password"
                    }
                ],
                ...
            }
        ],
        ...
    }
    

    For more granular configuration you should read the documentation of the redis docker image I posted above.