アプリ開発備忘録

PlayStationMobile、Android、UWPの開発備忘録

WSL2のDockerトラブルシューティング

環境

Ubuntu

ECRにログインできない場合

AWSのECRの説明どおりにコマンドを実行すると、docker loginする時に問題が発生します。

time="2021-10-09T00:26:47+09:00" level=error msg="failed to create file hook: while creating logrus local file hook: unable to get 'APPDATA'"

その時は以下の部分を適当な値に変更します。
~/.docker/config.json

- "credsStore":"desktop.exe"
+ "_credsStore":"desktop.exe"

何故

The property credsStore specifies an external binary to serve as the default credential store. When this property is set, docker login will attempt to store credentials in the binary specified by docker-credential- which is visible on $PATH. If this property is not set, credentials will be stored in the auths property of the config. For more information, see the Credentials store section in the docker login documentation https://docs.docker.com/engine/reference/commandline/cli/

credsStoreは、デフォルトの資格情報ストアとして機能する外部バイナリを指定します。

なので、 docker-credential-desktop.exe がデフォルトの資格情報ストアにっているのでこれを無効化しました。

sudoが求められる場合

dockerのグループを作成して、自分を追加します。

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

dockerで使用するファイルの権限を自分のユーザーに書き換えます。

sudo chown root:docker /var/run/docker.sock
sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
sudo chmod g+rwx "$HOME/.docker" -R

https://linuxhandbook.com/docker-permission-denied/