LoginSignup
0
0

【Docker x AWS】CLIで「Error saving credentials: error storing credentials - err: exit status 1, out:」エラーが出た場合

Posted at

エラー内容

いつものようにCLIログインをしたら以下のエラーが出てきました。

Error saving credentials: error storing credentials - err: exit status 1, out: `Post "http://ipc/registry/credstore-updated": dial unix backend.sock: connect: connection refused`

原因と解決方法

なんじゃこりゃ?と思い、調べてみると、、

Docker Desktopを起動していなかっただけでした...

エラーメッセージは、CLIログインコマンドを実行する際に、認証情報を保存するためのストレージが利用できないことを示しています。エラーメッセージの中には、backend.sock: connect: no such file or directoryという部分がありますが、これはバックエンドのソケットファイルが見つからないことを示しています。

今回はDockerデーモンが起動していない(Dockerデスクトップを起動していない)ことが原因で、CLIが必要なバックエンドソケットファイルにアクセスできていなかったですが、調べていると.docker/config.jsonのパラメータに問題があるケースもあるようです。

cat ~/.docker/config.json

上記を実行すると、以下のように認証情報が見れます。

{
	"auths": {
		"xxxxxxxxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com": {},
		"xxxxxxxxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com": {},
		"xxxxxxxxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com": {}
	},
	"credsStore": "desktop"

"credsStore": "desktop"とは、CLIが認証情報(ログイン情報)を保存する方法のことで、desktopの場合は認証情報をデスクトップアプリケーション経由で保存している、と言うことを意味しているのだそう。
私の場合はDocker Desktopを使っているのでそう表示されています。

一般的にはデスクトップアプリケーションを介して保存および取得した方がセキュリティ的に良いでしょう。
ただし、ここを削除したり、もしくはこのjsonごと削除することで、エラーが消えた、という記事もいくつかありました。

参考

credential storeについては、公式ドキュメントで以下のように記載がありましたので、ご参考までに。
docker login

ログインすると、そのコマンドが$HOME/.docker/config.jsonに認証情報を保存する、とあります。本エラーになった場合はその辺が関係してくると思われます。

You can log into any public or private repository for which you have credentials. When you log in, the command stores credentials in $HOME/.docker/config.json on Linux or %USERPROFILE%/.docker/config.json on Windows, via the procedure described below.

The Docker Engine can keep user credentials in an external credential store, such as the native keychain of the operating system. Using an external store is more secure than storing credentials in the Docker configuration file.

You need to specify the credential store in $HOME/.docker/config.json to tell the docker engine to use it. The value of the config property should be the suffix of the program to use (i.e. everything after docker-credential-). For example, to use docker-credential-osxkeychain:
{
"credsStore": "osxkeychain"
}
If you are currently logged in, run docker logout to remove the credentials from the file and run docker login again.

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