Dockerhubで「fatal: Could not read from remote repository」が出る場合はgit repository(github)でssh-keyを登録する


事象

dockerhubでbuildを行ったら以下のエラー発生。

Building in Docker Cloud's infrastructure...
Cloning into '.'...
Warning: Permanently added the RSA host key for IP address '192.30.253.112' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
please ensure the correct public key is added to the list of trusted keys for this repository (128)

対処

dockerhubのsshkeyを取得

git repository(github)でssh-keyを登録する
下記のdeploy keyをコピー

githubへsshkeyを登録

https://github.com/settings/keys
からadd newしてsshkeyを登録

Build再実行

成功を確認