Manjaro中的docker-credential-pass安装使用

写在前边

今天学习发布一个Docker镜像包,到了 docker login 环节抛了一个warning

如图所示
显而易见,密码存储不安全,建议我们配置一个凭据帮助程序来存储。说干就干,Just do it

打开上图中的链接

1
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

找到源码地址

1
https://github.com/docker/docker-credential-helpers

注意 README 中有一段话

Note

pass needs to be configured for docker-credential-pass to work properly. It must be initialized with a gpg2 key ID. Make sure your GPG key exists is in gpg2 keyring as pass uses gpg2 instead of the regular gpg.

OK.了解,在 Linux 下边,需要配置一下 pass。这就是我们需要的工具,接下来进入正式的安装和配置。

Manjaro 中的 docker-credential-pass 安装使用

Install pass

1
yay -S pass

Download docker-credential-pass

1
2
wget https://github.com/docker/docker-credential-helpers/releases/download/v0.6.0/docker-credential-pass-v0.6.0-amd64.tar.gz
tar -xf docker-credential-pass-v0.6.0-amd64.tar.gz

Install docker-credential-pass

1
2
chmod +x docker-credential-pass
sudo mv docker-credential-pass /usr/local/bin/

Create a new gpg2 key

1
2
3
4
5
$ gpg2 --gen-key
...
Real name: <Your Name>
Email address: <Your Email>
...

Initialize pass using the newly created key

1
pass init "<Your Name>"

配置你的 config

Add credsStore to your docker config. This can be done with sed if you don’t already have credStore added to your config or you can manually add “credStore”:”pass” to the config.json.

1
sed -i '0,/{/s/{/{\n\t"credsStore": "pass",/' ~/.docker/config.json

Login to docker

1
2
3
4
5
$ 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: yiranzai
Password:
Login Succeeded

搞定,结束。

End

Happy Coding,继续生产 BUG

Bye~

文章不错,你都不请我喝杯茶,就是说你呀!
0%
upyun