aws / amazon-ecs-cli

The Amazon ECS CLI enables users to run their applications on ECS/Fargate using the Docker Compose file format, quickly provision resources, push/pull images in ECR, and monitor running applications on ECS/Fargate.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_CLI.html
Other
1.78k stars 303 forks source link

docker image runs ok locally but in ECS I get a message: "python" executable file not found in $PATH #1136

Open cocodrino opened 3 years ago

cocodrino commented 3 years ago

Hi guys, I've a weird error, I'm trying to run a python script in ECS, the dockerfile is pretty basic:

FROM python:3.8
COPY . /
RUN pip install -r requirements.txt
CMD  ["python", "./get_historical_data.py"]

I can upload to ECR perfectly, even I can use inside EC2:

docker run -it  -e TICKER='SOL/USDT' -e EXCHANGE='BINANCE' -e DB_HOST='xxx' -e DB_NAME='xxx' -e DB_PASSWORD='xxx' -e DB_PORT='xxx' -e DB_USER='xxx' xxx.dkr.ecr.ap-southeast-2.amazonaws.com/xxx:latest /bin/bash

this run perfectly in my EC2 instance for ECS, but every time that I try run the task I get this error

Status reason   CannotStartContainerError: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "python": executable file not found in $PATH: unknown

my task definition is this

{
  "ipcMode": null,
  "executionRoleArn": null,
  "containerDefinitions": [
    {
      "dnsSearchDomains": null,
      "environmentFiles": null,
      "logConfiguration": null,
      "entryPoint": [],
      "portMappings": [],
      "command": [],
      "linuxParameters": null,
      "cpu": 0,
      "environment": [
        {
          "name": "ACTOR_MAX_CANDLES_TO_RETRIEVE_BY_CALL",
          "value": "1000"
        },
        {
          "name": "ACTOR_RETRY_MAX_TIME_SECONDS",
          "value": "600"
        },
        {
          "name": "ACTOR_RETRY_TIME_SECONDS",
          "value": "60"
        },
        {
          "name": "DB_HOST",
          "value": "172.31.3.xxxx"
        },
        {
          "name": "DB_NAME",
          "value": "xxx"
        },
        {
          "name": "DB_PASSWORD",
          "value": "xxx"
        },
        {
          "name": "DB_PORT",
          "value": "5438"
        },
        {
          "name": "DB_USER",
          "value": "xxx"
        },
        {
          "name": "EXCHANGE",
          "value": "xxx"
        },
        {......more env vars here.....}
      ],
      "resourceRequirements": null,
      "ulimits": null,
      "dnsServers": null,
      "mountPoints": [],
      "workingDirectory": null,
      "secrets": null,
      "dockerSecurityOptions": null,
      "memory": 512,
      "memoryReservation": null,
      "volumesFrom": [],
      "stopTimeout": null,
      "image": "176xxxx978.dkr.ecr.ap-southeast-2.amazonaws.com/historical-price:latest",
      "startTimeout": null,
      "firelensConfiguration": null,
      "dependsOn": null,
      "disableNetworking": null,
      "interactive": null,
      "healthCheck": null,
      "essential": true,
      "links": null,
      "hostname": null,
      "extraHosts": null,
      "pseudoTerminal": null,
      "user": null,
      "readonlyRootFilesystem": null,
      "dockerLabels": null,
      "systemControls": null,
      "privileged": null,
      "name": "historical-price-container"
    }
  ],
  "placementConstraints": [],
  "memory": "512",
  "taskRoleArn": null,
  "compatibilities": [
    "EXTERNAL",
    "EC2"
  ],
  "taskDefinitionArn": "arn:aws:ecs:ap-southeast-2:xxxx4978:task-definition/bb-historical-price-task-sol-usdt:5",
  "family": "bb-historical-price-task-sol-usdt",
  "requiresAttributes": [
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.ecr-auth"
    }
  ],
  "pidMode": null,
  "requiresCompatibilities": [
    "EC2"
  ],
  "networkMode": null,
  "runtimePlatform": null,
  "cpu": "1024",
  "revision": 5,
  "status": "ACTIVE",
  "inferenceAccelerators": null,
  "proxyConfiguration": null,
  "volumes": []
}

I've tried several dockerfiles, using

CMD python ./get_historical_data.py

or using python3 command instead of python

also I tried to skip the CMD command in the Dockerfile and add this in the ECS task definition

nothing work...

do you know what could be the issue?

right now I'm building the ECR image through a gitlab runner, I don't think that this can be the problem because I can run the image perfectly in the server

hope you can help me, thank you so much

udaykirankavaturu commented 1 year ago

I have this same issue. Did you find a fix?