Amazon-ecs-agent: CannotStartContainerError: API error (404)

Created on 26 Feb 2017  路  2Comments  路  Source: aws/amazon-ecs-agent

I am trying to deploy a php application via aws ecs.
After I start the Task inside the Cluster the following error occurs:
Status CannotStartContainerError: API error (404): invalid header field value "oci runtime error: container_linux.go:247:
reason starting container process caused \"exec: \\"apt-get update \\\\\\n && apt-get -y --no-install-recommends install php-memcached p
Command ["apt-get update \\n && apt-get -y --no-install-recommends install php-memcached php7.1-mysql php7.1-bcmath php7.1-bz2 php-yaml php-xdebug \\n && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*"]

I am using the amzn-ami-2016.09.f-amazon-ecs-optimized (ami-a7f2acc1) AMI.

My Task Definition:

{
"requiresAttributes": [
{
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.17",
"targetId": null,
"targetType": null
},
{
"value": null,
"name": "com.amazonaws.ecs.capability.privileged-container",
"targetId": null,
"targetType": null
},
{
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18",
"targetId": null,
"targetType": null
},
{
"value": null,
"name": "com.amazonaws.ecs.capability.task-iam-role",
"targetId": null,
"targetType": null
},
{
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.21",
"targetId": null,
"targetType": null
}
],
"taskDefinitionArn": "arn:aws:ecs:eu-west-1:261019727774:task-definition/LaendleOnline:8",
"networkMode": "bridge",
"status": "ACTIVE",
"revision": 8,
"taskRoleArn": "arn:aws:iam::261019727774:role/LaendleOnlineTask",
"containerDefinitions": [
{
"volumesFrom": [],
"memory": 1000,
"extraHosts": null,
"dnsServers": null,
"disableNetworking": null,
"dnsSearchDomains": null,
"portMappings": [],
"hostname": null,
"essential": true,
"entryPoint": null,
"mountPoints": [],
"name": "laendleonline-memcached",
"ulimits": null,
"dockerSecurityOptions": null,
"environment": [],
"links": null,
"workingDirectory": null,
"readonlyRootFilesystem": null,
"image": "phpdockerio/memcached:latest",
"command": null,
"user": null,
"dockerLabels": {
"Customer": "LaendleOnline"
},
"logConfiguration": null,
"cpu": 0,
"privileged": true,
"memoryReservation": 100
},
{
"volumesFrom": [],
"memory": 1000,
"extraHosts": null,
"dnsServers": null,
"disableNetworking": null,
"dnsSearchDomains": null,
"portMappings": [],
"hostname": null,
"essential": true,
"entryPoint": null,
"mountPoints": [],
"name": "laendleonline-mysql",
"ulimits": null,
"dockerSecurityOptions": null,
"environment": [
{
"name": "MYSQL_DATABASE",
"value": "symfony"
},
{
"name": "MYSQL_PASSWORD",
"value": "password"
},
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "password"
},
{
"name": "MYSQL_USER",
"value": "sa"
}
],
"links": null,
"workingDirectory": null,
"readonlyRootFilesystem": false,
"image": "mysql:5.7",
"command": null,
"user": null,
"dockerLabels": {
"Customer": "LaendleOnline"
},
"logConfiguration": null,
"cpu": 0,
"privileged": true,
"memoryReservation": 100
},
{
"volumesFrom": [],
"memory": 1000,
"extraHosts": null,
"dnsServers": null,
"disableNetworking": null,
"dnsSearchDomains": null,
"portMappings": [
{
"hostPort": 80,
"containerPort": 80,
"protocol": "tcp"
}
],
"hostname": null,
"essential": true,
"entryPoint": null,
"mountPoints": [
{
"containerPath": "/var/www/laendleonline",
"sourceVolume": "laendleonline-efs",
"readOnly": null
},
{
"containerPath": "/etc/nginx/conf.d/default.conf",
"sourceVolume": "laendleonline-nginxconf-efs",
"readOnly": true
}
],
"name": "laendleonline-webserver",
"ulimits": null,
"dockerSecurityOptions": null,
"environment": [],
"links": [
"laendleonline-php-fpm:laendleonline-php-fpm"
],
"workingDirectory": null,
"readonlyRootFilesystem": null,
"image": "phpdockerio/nginx:latest",
"command": null,
"user": null,
"dockerLabels": {
"Customer": "LaendleOnline"
},
"logConfiguration": null,
"cpu": 0,
"privileged": true,
"memoryReservation": 100
},
{
"volumesFrom": [],
"memory": 1000,
"extraHosts": null,
"dnsServers": null,
"disableNetworking": null,
"dnsSearchDomains": null,
"portMappings": [],
"hostname": null,
"essential": true,
"entryPoint": null,
"mountPoints": [
{
"containerPath": "/var/www/laendleonline",
"sourceVolume": "laendleonline-efs",
"readOnly": null
},
{
"containerPath": "/etc/php/7.1/fpm/conf.d/99-overrides.ini",
"sourceVolume": "laendleonline-phpconf-efs",
"readOnly": true
}
],
"name": "laendleonline-php-fpm",
"ulimits": null,
"dockerSecurityOptions": null,
"environment": [],
"links": [
"laendleonline-memcached:laendleonline-memcached",
"laendleonline-mysql:laendleonline-mysql"
],
"workingDirectory": "/var/www/laendleonline",
"readonlyRootFilesystem": null,
"image": "phpdockerio/php71-fpm:latest",
"command": [
"apt-get update \\n && apt-get -y --no-install-recommends install php-memcached php7.1-mysql php7.1-bcmath php7.1-bz2 php-yaml php-xdebug \\n && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*"
],
"user": null,
"dockerLabels": {
"Customer": "LaendleOnline"
},
"logConfiguration": null,
"cpu": 0,
"privileged": true,
"memoryReservation": 100
}
],
"placementConstraints": [],
"volumes": [
{
"host": {
"sourcePath": "/laendleonline-efs"
},
"name": "laendleonline-efs"
},
{
"host": {
"sourcePath": "/laendleonline-nginxconf-efs"
},
"name": "laendleonline-nginxconf-efs"
},
{
"host": {
"sourcePath": "/laendleonline-phpconf-efs"
},
"name": "laendleonline-phpconf-efs"
}
],
"family": "LaendleOnline"
}

kinquestion

Most helpful comment

Hi @orlandothoeny,

It looks like your container is unable to execute the command provided in the task definition.

"Command" expects an array of strings which will be executed as argv. When the arguments are given as one string, docker only sees it as an argv[0]. It will try to execute a program called apt-get update && \\... instead of recognizing space-delimited arguments.

One way to fix this is by adding an entry point to your task definition:

"entryPoint": ["sh", "-c"]

If the issue persists, could you provide additional docker logs from the host? Documentaion is available here.

All 2 comments

Hi @orlandothoeny,

It looks like your container is unable to execute the command provided in the task definition.

"Command" expects an array of strings which will be executed as argv. When the arguments are given as one string, docker only sees it as an argv[0]. It will try to execute a program called apt-get update && \\... instead of recognizing space-delimited arguments.

One way to fix this is by adding an entry point to your task definition:

"entryPoint": ["sh", "-c"]

If the issue persists, could you provide additional docker logs from the host? Documentaion is available here.

Thank you, solved my problem.

Was this page helpful?
0 / 5 - 0 ratings