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?

Datadog image pull & push(Public ECR to Private ECR)

Last updated at Posted at 2025-02-24

はじめに

監視ツールDatadogのImageがpublic ECRにあり、閉域網内のECSでDatadogを利用するため、Public ECRのイメージを取得し、Private ECRにプッシュする必要があります。
その際、CPUアーキテクチャに注意すべきです。

やり方

  • 「docker pull」でPublic ECRからDatadog imageをpull
  • 「docker push」でPrivate ECRにDatadog imageをpush

実際に発行したコマンド①

$ docker pull public.ecr.aws/datadog/agent:latest
$ docker tag public.ecr.aws/datadog/agent:latest 123456789000.dkr.ecr.ap-northeast-1.amazonaws.com/test:latest
$ aws ecr get-login-password --region ap-northeast-1 | docker login --username AWS --password-stdin 123456789000.dkr.ecr.ap-northeast-1.amazonaws.com
$ docker push 123456789000.dkr.ecr.ap-northeast-1.amazonaws.com/test:latest

エラー

上記の通り、Datadog ImageをPrivate ECRに格納しましたが、ECS taskを起動した結果、エラーが発生しました。

exec /usr/bin/npm: exec format error

原因

x86とARMのミスマッチ問題でした。

  • ECSのInfrastructure:Linux/ARM64
  • docker engineの実行環境:WSLで実行したため、linux/x86_64
$ docker system info --format '{{.OSType}}/{{.Architecture}}'
linux/x86_64

docker pullをoption指定なしで実行すると、実行環境と同じArchitectureのimageがpullされるため、以下の通り「platform」を指定することが必要です。

docker pull --platform linux/arm64 public.ecr.aws/datadog/agent:latest

コマンド(修正版)

$ docker pull --platform linux/arm64 public.ecr.aws/datadog/agent:latest
$ aws ecr get-login-password --region ap-northeast-1 | docker login --username AWS --password-stdin 123456789000.dkr.ecr.ap-northeast-1.amazonaws.com
$ docker tag public.ecr.aws/datadog/agent:latest 123456789000.dkr.ecr.ap-northeast-1.amazonaws.com/test:latest
$ docker push 123456789000.dkr.ecr.ap-northeast-1.amazonaws.com/test:latest

備考

コストが安く、性能が高いため、今回はAWSの推奨通りARMを利用しました。
https://tech-blog.yayoi-kk.co.jp/entry/2024/08/09/110000

個人的な考えとしては、AWSにおけるARMの利用はまだMinorと思われますので、主流のやり方(Linux/x86_64)を選択したほうが無難ですが、ARMはRISC(reduced instruction set computer)構造ですので、省電力のメリットもあります。

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?