4

docker 可视化容器管理工具 - Portainer 忘记用户名密码 解决办法

 3 years ago
source link: https://hellodk.cn/post/468
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Xnip2021-03-25_12-01-38.png

忘记 portainer 密码,默认用户 admin

1. 停止 portainer 容器

使用 docker ps -a 找到对应的容器名字 或者 id

$ sudo docker ps -a
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                      PORTS                  NAMES

62517d512798        portainer/portainer         "/portainer"             8 months ago        Exited (2) 17 minutes ago                          hungry_black

停止 portainer 容器 (命令里使用 container id 或 container name 都可以)

docker stop hungry_black

2. 借助仓库 portainer/helper-reset-password 重置密码

首先需要找到 volume data 宿主机所在的路径

寻找 portainer.key

find / -name portainer.key

发现路径是 /var/lib/docker/volumes/e09ff18cd1ecb7243e3152e6d89c0a48a706ffe4affa15d17de6c74c79021c23/_data/portainer.key

于是可以重置密码了

docker run --rm -v /var/lib/docker/volumes/e09ff18cd1ecb7243e3152e6d89c0a48a706ffe4affa15d17de6c74c79021c23/_data:/data portainer/helper-reset-password

本地 images 找不到这个镜像 会从配置的 registry 拉取镜像

Unable to find image 'portainer/helper-reset-password:latest' locally
latest: Pulling from portainer/helper-reset-password
79916c70cb9e: Pull complete
93e26fa95550: Pull complete
Digest: sha256:735a809b1bfe14b5fae340d4b350bae97c2016371c47fb6e34d71a45e4512f79
Status: Downloaded newer image for portainer/helper-reset-password:latest
2021/03/25 04:00:14 Password succesfully updated for user: admin
2021/03/25 04:00:14 Use the following password to login: |OP\L,2e&9+0x378cDTh#Q56bi*xxx

3. 启动容器测试

启动容器
docker start hungry_black

打开 portainer 管理页面测试
http://YOUR_IP:9000

输入用户名 admin 密码 |OP\L,2e&9+0x378cDTh#Q56bi*xxx 然后登录成功!

4. 修改密码

image.png

登录后右上角 「my account」 里修改密码,至少8个字符

Reference

Reset password for the Admin user


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK