LoginSignup
2
2

More than 3 years have passed since last update.

amazon-ecr-credential-helperをWindowsにインストールする

Posted at

amazon-ecr-credential-helperをWindowsにインストールする

Amazon ECRにWindowsからアクセスする際に、毎回ログインが必要で面倒だったので、ログインしなくて済む方法を探したところ、 amazon-ecr-credential-helper というのがあると知り、Windowsにインストールしてみました。
結構苦戦したので、忘れない内にメモに残します。

AWSアクセスキーの設定

AWSへアクセスするための AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY の設定をしていなければ、設定します。

設定方法はこちらがわかりやすいです。
~/.aws/credentialsファイルでプロファイルを切り替える

Golangのインストール

Go言語をインストールしていない場合は、インストールします。

こちらがとても参考になります。
WindowsにGo言語をインストールする方法まとめ

makeのインストール

makeをインストールしていない場合は、インストールします。

こちらがとても参考になります。
windowsでmakeコマンドを使用する方法

Dockerの設定ファイルの編集

%USERPROFILE%\.docker\config.json を編集します。なければ作ります。

以下の内容を追記します。

{
  "credsStore": "ecr-login"
}

amazon-ecr-credential-helperのビルド

以下のコマンドでビルドができます。

rem ソースコードをダウンロード
go get github.com/awslabs/amazon-ecr-credential-helper

rem ダウンロードしたフォルダへ移動
cd %GOPATH%\src\github.com\awslabs\amazon-ecr-credential-helper

rem ビルド
make docker TARGET_GOOS=windows

これで、 cd %GOPATH%\src\github.com\awslabs\amazon-ecr-credential-helper\bin\local\docker-credential-ecr-login が生成されます。(これに気付くのに時間かかった・・・)

このファイルをPathの通ったフォルダにコピーします。ここでは、 %GOPATH%\bin\ とします。

rem ファイルコピー
copy %GOPATH%\src\github.com\awslabs\amazon-ecr-credential-helper\bin\local\docker-credential-ecr-login %GOPATH%\bin\docker-credential-ecr-login

rem バージョン確認
docker-credential-ecr-login -v

バージョン確認をして、

amazon-ecr-credential-helper
Version:    master
Git commit:

と表示されたらインストールは成功です。

さいごに

こちらを参考にさせていただきました。わかりやすい記事ありがとうございました。

2
2
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
2