2
1

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 3 years have passed since last update.

[ECS]Dockerfileでコンテナ実行時に起動されるコマンドをTerraformで定義する際のTips

2
Last updated at Posted at 2023-03-23

ENTRYPOINTとCMDは、Dockerfileでコンテナ実行時にコマンド定義するために使用します

  • ENTRYPOINT
    ENTRYPOINTは、コンテナが実行される際にデフォルトで実行されるコマンドを指定します。ENTRYPOINTで指定されたコマンドは、コンテナ実行時に上書きすることができますが、通常はコンテナのメインプロセスやアプリケーションの実行に使用する

  • CMD
    CMDは、コンテナが実行される際にENTRYPOINTに渡すデフォルトの引数を指定する


  • ENTRYPOINTはコンテナのメインコマンドを定義し、CMDはそのコマンドに対するデフォルトの引数を定義する
ENTRYPOINT ["/app/myapp"]
CMD ["--help"]

/app/myapp --help

  • TIPS
    • ECSタスク定義では、ENTRYPOINTとCMDを組み合わせることができないので、commandを使用してENTRYPOINTとCMDを組み合わせて制御します。
cloudwatch_event_targe.tf
resource "aws_cloudwatch_event_target" "example" {
  for_each = local.example
  # ...
  input = jsonencode({
    containerOverrides = [
      {
        name    = "example",
        command = each.value.example
      }
    ]
  })
locals.tf
locals {
  example = {
  # ...
      container_overrides = [
        {
          name    = "example"
          command = ["/app/myapp", "--help"] // ["entrypoint_command", "cmd_argument_1"]
        }
      ]
    }
2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?