0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[AWS Batch] CannotStartContainerError: executable file not found in $PATH で AWS Batch が動かない時の対策

Posted at

症状

  • AWS Batch > ジョブ > 詳細を確認すると、結果がFailedになっていた
  • 同ページ内の、コンテナと書かれたカードの理由欄に以下のようなエラーが吐き出されていた。
CannotStartContainerError: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"which python\": executable file not found in $PATH": unknown

AWS Batch > ジョブ > 詳細ページは以下のような感じになっている。

2022-10-28_19h00_39.png

&& lsは気にしないで...debugしたかったの...。

原因

原因は簡単で、serverless frameworkのCommandの記載方法が間違っていた。

serverless.ymlの一部
Resources:
  TrialJobDefinition:
    Type: AWS::Batch::JobDefinition
    Properties:
      JobDefinitionName: ${self:custom.job_definition_name}
      Type: container
      ContainerProperties:
        Image: !Sub '${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/${self:custom.image_name}:latest'
        Memory: 512
        Vcpus: 1
        Command:
          - python main.py  # <--- ダメ

対策

Command部分を以下のように直したところ、正常に動作した。

serverless.ymlの一部
Resources:
  TrialJobDefinition:
    Type: AWS::Batch::JobDefinition
    Properties:
      JobDefinitionName: ${self:custom.job_definition_name}
      Type: container
      ContainerProperties:
        Image: !Sub '${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/${self:custom.image_name}:latest'
        Memory: 512
        Vcpus: 1
        Command: ["python", "main.py"]  # <--- OK

DockerfileのCMDと同じ書き方をしないといけないらしい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?