Score:0

How to pass arguments into scheduled task on AWS Fargate?

gb flag

I have a docker container (derived from PHP-CLI) that may be launched like this locally:

  • docker run php-cli-container php public/index.php argument1 argument2

I uploaded the container to Amazon AWS ECR and implemented it into an ECS scheduled task. Everything is set up properly and the task is actually running on AWS now every hour.

The input is stored in EventBridge as follows:

{
  "containerOverrides": [{
    "name": "php-api-cli",
    "command": ["php public/index.php argument1 argument2"]
  }]
}

Unfortunately, this does not seem to work. CloudWatch reports the following error:

  • /usr/local/bin/docker-php-entrypoint: 9: exec: php public/index.php argument1 argument2: not found

How do I correctly pass the argument php public/index.php argument1 argument2 into the AWS Fargate task?

Score:0
gb flag

To achieve what OP wants, we have to write:

{
  "containerOverrides": [{
    "name": "php-api-cli",
    "command": ["php", "public/index.php", "argument1", "argument2"]
  }]
}

Explanation:

AWS passes docker run php-cli-container "php public/index.php argument1 argument2" to the container in the case of OP.

To avoid that issue, we have to separate all arguments into seperate string values into the command array.

andreas avatar
gb flag
If you use the AWS console through ECS, just enter the command overrides as follows: `php,public/index.php,argument1,argument2` (without spaces, quotes or brackets)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.