Mac で docker login や docker-compose build や up 時に User interaction is not allowed エラー。はたまた docker.credentials.errors.StoreError のたぐい

## [xxxx] Failed to execute script docker-compose
> macOS Mojave（MacOS 10.14.6）で `docker login` `docker pull` や `docker-compose up` `docker-compose build` すると `error storing credentials` `User interaction is not allowed` が出ます。

```
$ docker-compose up -d
Building mc1
Traceback (most recent call last):
  File "site-packages/docker/credentials/store.py", line 80, in _execute
  File "subprocess.py", line 411, in check_output
  File "subprocess.py", line 512, in run
subprocess.CalledProcessError: Command '['/usr/local/bin/docker-credential-desktop', 'get']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages/docker/auth.py", line 264, in _resolve_authconfig_credstore
  File "site-packages/docker/credentials/store.py", line 35, in get
  File "site-packages/docker/credentials/store.py", line 93, in _execute
docker.credentials.errors.StoreError: Credentials store docker-credential-desktop exited with "error getting credentials - err: exit status 1, out: `User interaction is not allowed.`".

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose/cli/main.py", line 72, in main
  File "compose/cli/main.py", line 128, in perform_command
  File "compose/cli/main.py", line 1077, in up
  File "compose/cli/main.py", line 1073, in up
  File "compose/project.py", line 548, in up
  File "compose/service.py", line 367, in ensure_image_exists
  File "compose/service.py", line 1106, in build
  File "site-packages/docker/api/build.py", line 261, in build
  File "site-packages/docker/api/build.py", line 308, in _set_auth_headers
  File "site-packages/docker/auth.py", line 304, in get_all_credentials
  File "site-packages/docker/auth.py", line 281, in _resolve_authconfig_credstore
docker.errors.DockerException: Credentials store error: StoreError('Credentials store docker-credential-desktop exited with "error getting credentials - err: exit status 1, out: `User interaction is not allowed.`".')
[5011] Failed to execute script docker-compose

```

## TL; DR

> **ログイン情報を KeyChain に書き込めないことによるエラー**です。
> 
> `security` コマンドの `unlock-keychain` で、**アンロックして KeyChain に追加できるようにします**。パスワードは macOS にログイン中のアカウントのパスワードです。

```shell-session
$ security unlock-keychain
password to unlock default: 
```

## TS; DR

ローカルでビルドした Docker イメージを、Docker Hub にプッシュするために Docker アカウントにログインする必要がありました。（`docker login` → `docker push`）

しかし、他の Mac では `docker login` 出来たのに、SSH 接続したヘッドレスの Mac ではログインできなかったのです。

```shell-session
$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a
Docker ID, head over to https://hub.docker.com to create one.
Username: keinos
Password: 
Error saving credentials: error storing credentials - err: exit status 1, out: `error
storing credentials - err: exit status 1, out: `User interaction is not allowed.``
```

アカウント名とパスワードが同じなのはコピペピピックして確認済みです。

また、`docker-compose up` でイメージがダウンロードされる場合にも表示されることがあります。

```shell-session
$ docker-compose up --build
Pulling bungeecord (itzg/bungeecord:)...
Traceback (most recent call last):
  File "site-packages/docker/credentials/store.py", line 80, in _execute
  File "subprocess.py", line 411, in check_output
  File "subprocess.py", line 512, in run
subprocess.CalledProcessError: Command '['/usr/local/bin/docker-credential-desktop', 'get']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages/docker/auth.py", line 264, in _resolve_authconfig_credstore
  File "site-packages/docker/credentials/store.py", line 35, in get
  File "site-packages/docker/credentials/store.py", line 93, in _execute
docker.credentials.errors.StoreError: Credentials store docker-credential-desktop exited with "error getting credentials - err: exit status 1, out: `User interaction is not allowed.`".

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose/cli/main.py", line 72, in main
  File "compose/cli/main.py", line 128, in perform_command
  File "compose/cli/main.py", line 1077, in up
  File "compose/cli/main.py", line 1073, in up
  File "compose/project.py", line 548, in up
  File "compose/service.py", line 361, in ensure_image_exists
  File "compose/service.py", line 1250, in pull
  File "compose/progress_stream.py", line 102, in get_digest_from_pull
  File "compose/service.py", line 1215, in _do_pull
  File "site-packages/docker/api/image.py", line 396, in pull
  File "site-packages/docker/auth.py", line 48, in get_config_header
  File "site-packages/docker/auth.py", line 324, in resolve_authconfig
  File "site-packages/docker/auth.py", line 235, in resolve_authconfig
  File "site-packages/docker/auth.py", line 281, in _resolve_authconfig_credstore
docker.errors.DockerException: Credentials store error: StoreError('Credentials store docker-credential-desktop exited with "error getting credentials - err: exit status 1, out: `User interaction is not allowed.`".')
[4023] Failed to execute script docker-compose
```

落ち着いてエラー内容を読むと、`error storing credentials`（「認証情報の保存エラー」） とあるのでログイン情報の保存時にエラーが発生しているようです。

また、続けて `User interaction is not allowed`（「ユーザとのやりとりは禁止されています」） とあるので、権限的な問題が原因のようです。

せやかて `sudo` て、と不安になりましたが[「docker login User interaction is not allowed」でググった](https://www.google.com/search?q=docker+login+User+interaction+is+not+allowed)ら出てきた以下の Qiita 記事で一発解消。古い記事ですが、2019 年末現在も有効でした。

- [docker-compose 実行時の User interaction is not allowed エラー](https://qiita.com/Ping/items/03176a74e9c25153ea08) @ Qiita

助かりました。