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?
"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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With