

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# EcsProperties を使用してジョブ定義を作成する
<a name="multi-container-jobs"></a>

を使用した AWS Batch ジョブ定義を使用すると[https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html)、ハードウェア、センサー、3D 環境、その他のシミュレーションを別々のコンテナでモデル化できます。この機能を使用することでワークロードコンポーネントを論理的に整理し、これらをメインアプリケーションから分離できます。この機能は、Amazon Elastic Container Service (Amazon ECS)、Amazon Elastic Kubernetes Service (Amazon EKS)、および AWS Batch の で使用できます AWS Fargate。

## `ContainerProperties` と `EcsProperties` のジョブ定義
<a name="containerpropertions-vs-ecsproperties"></a>

ユースケースに応じて、[https://docs.aws.amazon.com/batch/latest/APIReference/API_ContainerProperties.html](https://docs.aws.amazon.com/batch/latest/APIReference/API_ContainerProperties.html) または [https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html) のジョブ定義の使用を選択できます。高レベルでは、 で実行中の AWS Batch ジョブ`EcsProperties`は、 で実行中のジョブと似ています`ContainerProperties`。

`ContainerProperties` を使用する従来のジョブ定義構造は引き続きサポートされます。現在この構造を使用するワークフローがある場合は引き続き実行できます。

主な違いは、`EcsProperties` ベースの定義に対応するため、ジョブ定義に新しいオブジェクトが追加されていることです。

例えば、Amazon ECS と Fargate で `ContainerProperties` を使用するジョブ定義は次のような構造になります。

```
{
   "containerProperties": {
     ...
     "image": "my_ecr_image1",
     ...
  },
...
}
```

Amazon ECS と Fargate で `EcsProperties` を使用するジョブ定義は次のような構造になります。

```
{
  "ecsProperties": {
    "taskProperties": [{
      "containers": [
        { 
          ...
          "image": "my_ecr_image1",
          ...
        },
        { 
          ...
          "image": "my_ecr_image2",
          ...
        },
```

## AWS Batch APIs の一般的な変更
<a name="multi-container-general"></a>

`ContainerProperties` と `EcsProperties` API データ型を使用する際の主な違いは以下のとおりです。
+ `ContainerProperties` で使用されるパラメータの多くは、`TaskContainerProperties` でも使用されます。例えば、`command`、`image`、`privileged`、`secrets`、`users` です。これらはすべて「[TaskContainerProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html)」で説明しています。
+ 一部の `TaskContainerProperties` パラメータには従来の構造に機能的に同等なものがありません。例えば、`dependsOn`、`essential`、`name`、`ipcMode`、`pidMode` です。詳細は「[EcsTaskDetails](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsTaskDetails.html)」と「[TaskContainerProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html)」を参照してください。

  また、一部の `ContainerProperties` パラメータには `EcsProperties` 構造に機能的に同等なものやアプリケーションがありません。[https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html#Batch-Type-EcsProperties-taskProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html#Batch-Type-EcsProperties-taskProperties) では、新しいオブジェクトが最大 10 個の要素を受け入れることができるように、`container` が `containers` に置き換えられました。詳細は「[RegisterJobDefinition:containerProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#Batch-RegisterJobDefinition-request-containerProperties)」および「[EcsTaskProperties:containers](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsTaskProperties.html)」を参照してください。
+ `taskRoleArn` は機能的に `jobRoleArn` と同等です。詳細は「[EcsTaskProperties:taskRoleArn](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsTaskProperties.html)」および「[ContainerProperties:jobRoleArn](https://docs.aws.amazon.com/batch/latest/APIReference/API_ContainerProperties.html)」を参照してください。
+ `EcsProperties` 構造には 1～10 個のコンテナを含めることができます。詳細は「[EcsTaskProperties:containers](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsTaskProperties.html)」を参照してください。
+ `taskProperties` および instanceTypes オブジェクトは配列ですが、現在受け入れることができるのは 1 つの要素のみです。例えば、[EcsProperties:taskProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html) と [NodeRangeProperty:instanceTypes](https://docs.aws.amazon.com/batch/latest/APIReference/API_NodeRangeProperty.html) です。

## Amazon ECS のマルチコンテナのジョブ定義
<a name="multi-container-ecs-updates"></a>

Amazon ECS のマルチコンテナ構造に対応するため、API データ型が異なることがあります。例えば、
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#Batch-RegisterJobDefinition-request-ecsProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#Batch-RegisterJobDefinition-request-ecsProperties) は、単一コンテナ定義では `containerProperties` と同じレベルです。詳細については、「*AWS Batch API リファレンスガイド*」の「[EcsProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html)」を参照してください。
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html#Batch-Type-EcsProperties-taskProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html#Batch-Type-EcsProperties-taskProperties) には、Amazon ECS タスク用に定義されたプロパティが含まれます。詳細については、「*AWS Batch API リファレンスガイド*」の「[EcsProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html)」を参照してください。
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsTaskProperties.html#Batch-Type-EcsTaskProperties-containers](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsTaskProperties.html#Batch-Type-EcsTaskProperties-containers) には、単一コンテナ定義での `containerProperties` と同様の情報が含まれます。主な違いは、`containers` では最大 10 個のコンテナを定義できる点です。詳細については、「*AWS Batch API リファレンスガイド*」の「[ECSTaskProperties:containers](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsTaskProperties.html)」を参照してください。
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html#Batch-Type-TaskContainerProperties-essential](https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html#Batch-Type-TaskContainerProperties-essential) パラメータは、そのコンテナがジョブにどのように影響するかを示します。ジョブを進行させるには、すべての essential コンテナが正常に完了 (0 で終了) する必要があります。essential としてマークされたコンテナが失敗した場合 (0 以外で終了)、ジョブは失敗します。

  デフォルト値は `true` で、少なくとも 1 つのコンテナを `essential` としてマークする必要があります。詳細については、[`essential` API リファレンスガイド](https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html#Batch-Type-TaskContainerProperties-essential)の「*AWS Batch *」を参照してください。
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html#Batch-Type-TaskContainerProperties-dependsOn](https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html#Batch-Type-TaskContainerProperties-dependsOn) パラメータを使用すると、コンテナの依存関係のリストを定義できます。詳細については、[`dependsOn` API リファレンスガイド](https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html#Batch-Type-TaskContainerProperties-dependsOn)の「*AWS Batch *」を参照してください。
**注記**  
`dependsOn` リストの複雑さと、関連するコンテナランタイムはジョブの開始時間に影響する可能性があります。依存関係の実行に時間がかかる場合、ジョブは完了するまで `STARTING` 状態のままになります。

`ecsProperties` と構造の詳細については、「[RegisterJobDefinition](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#API_RegisterJobDefinition_RequestBody)」リクエスト構文で「[ecsProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#Batch-RegisterJobDefinition-request-ecsProperties)」を参照してください。

## Amazon EKS のマルチコンテナのジョブ定義
<a name="multi-container-eks-updates"></a>

Amazon EKS のマルチコンテナ構造に対応するため、API データ型が異なることがあります。例えば、
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_EksContainer.html#Batch-Type-EksContainer-name](https://docs.aws.amazon.com/batch/latest/APIReference/API_EksContainer.html#Batch-Type-EksContainer-name) は、コンテナに対する一意の識別子です。このオブジェクトは単一のコンテナには必要ありませんが、ポッド内の複数のコンテナを定義するときは必要です。`name` が単一のコンテナに定義されていない場合は、デフォルト名の `default` が適用されます。
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_EksPodProperties.html#Batch-Type-EksPodProperties-initContainers](https://docs.aws.amazon.com/batch/latest/APIReference/API_EksPodProperties.html#Batch-Type-EksPodProperties-initContainers) は [eksPodProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_EksPodProperties.html) データ型内で定義されます。これらはアプリケーションコンテナの前に、常に完了するまで実行されます。また、次のコンテナが起動する前に正常に完了する必要があります。

  これらのコンテナは Amazon EKS Connector エージェントを使用して登録され、登録情報は Amazon Elastic Kubernetes Service のバックエンドデータストアに保持されます。`initContainers` オブジェクトは最大 10 個の要素を受け入れることができます。詳細については、*Kubernetes ドキュメント*の「[Init Containers](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/)」を参照してください。
**注記**  
`initContainers` オブジェクトは、ジョブの開始時刻に影響を与える可能性があります。`initContainers` の実行に時間がかかる場合、ジョブは完了するまで `STARTING` 状態のままになります。
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_EksPodProperties.html#Batch-Type-EksPodProperties-shareProcessNamespace](https://docs.aws.amazon.com/batch/latest/APIReference/API_EksPodProperties.html#Batch-Type-EksPodProperties-shareProcessNamespace) は、ポッド内のコンテナが同じプロセス名前空間を共有できるかどうかを示します。デフォルト値は `false` です。これを `true` に設定すると、コンテナは同じポッドにある他のコンテナのプロセスを認識してシグナルを送信できるようになります。
+ どのコンテナにも重要性があり、ジョブが成功するにはすべてのコンテナが正常に完了 (0 で終了) する必要があります。1 つのコンテナが失敗すると (0 以外で終了)、ジョブは失敗します。

`eksProperties` および構造の詳細については、「[RegisterJobDefinition](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#API_RegisterJobDefinition_RequestBody)」リクエスト構文で「[eksProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#Batch-RegisterJobDefinition-request-eksProperties)」を参照してください。