Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ECS invalid reference format error

I try to deploy and run a simple Dockerized Ruby backend using Amazon ECS by running a Task (defined by Task Definition) but it failed to run my command and returned this error:

CannotPullContainerError: API error (400): invalid reference format

I've tried to run a small Entrypoint command of echo "Hello" but it's returning the same error regardless it's exec form or shell form. I tried to run this command in my local terminal it's running well:

$ docker-compose run job echo 'HELLO_WORLD'
HELLO_WORLD

This is the error message as shown in the Details section of my cluster task:

Status reason   CannotPullContainerError: API error (400): invalid reference format
  Entry point   ["echo","HELLO"]

this is my Task Definition JSON (hiding certain information for security reason):

{
    "executionRoleArn": null,
    "containerDefinitions": [
        {
            "dnsSearchDomains": null,
            "logConfiguration": null,
            "entryPoint": [
                "echo",
                "HELLO"
            ],
            "portMappings": [],
            "command": [],
            "linuxParameters": null,
            "cpu": 0,
            "environment": [
                {
                    "name": "RAILS_ENV",
                    "value": "production"
                }
            ],
            "ulimits": null,
            "dnsServers": null,
            "mountPoints": [],
            "workingDirectory": null,
            "dockerSecurityOptions": null,
            "memory": 7000,
            "memoryReservation": null,
            "volumesFrom": [],
            "image": "<ecs_image_arn>",
            "disableNetworking": false,
            "healthCheck": null,
            "essential": true,
            "links": null,
            "hostname": null,
            "extraHosts": null,
            "user": null,
            "readonlyRootFilesystem": null,
            "dockerLabels": null,
            "privileged": null,
            "name": "<name>"
        }
    ],
    "memory": null,
    "taskRoleArn": "arn:aws:iam::<id>:role/<name>",
    "family": "<test-cluster>",
    "requiresCompatibilities": [
        "EC2"
    ],
    "networkMode": null,
    "cpu": null,
    "volumes": [],
    "placementConstraints": []
}

Changing entryPoint to use command doesn't work as well.

Status reason   CannotPullContainerError: API error (400): invalid reference format
    Command ["echo","HELLO"]

Am I missing out any configuration to make a simple echo command work?

like image 503
nayiaw Avatar asked Jul 24 '18 09:07

nayiaw


2 Answers

"Invalid reference format" means that the image name docker is trying to parse is invalid. In your logs:

   "image": "<ecs_image_arn>",

The image name is indeed invalid and needs to be replaced with a valid image name. If that string has been replaced by you in this question for privacy, then the part removed is where your error exists.

like image 69
BMitch Avatar answered Sep 23 '22 22:09

BMitch


Make sure to use the repository URI, not the ARN (if using an ECR image). Some AWS documentation (see "Image Not Found" section) describes the ARN as being a valid value, but it does not appear to work.

like image 30
Nathan Hanna Avatar answered Sep 26 '22 22:09

Nathan Hanna