🚀

Difyで管理者用アカウントをCUI上で初期化する方法

2024/12/25に公開

はじめに

一般的にはDifyの管理者アカウントのパスワードを忘れた場合は、ログイン画面にあるパスワードリセットを行えばよいです。
ですがCommunity版を使用している場合は.envファイルにメールサーバーの設定をしていない場合が多いのではないのでしょうか?
その場合はパスワードのリセットができなくなり、コンテナを作り直すしかなくなってしまいます。
私も2回ぐらいこの状況に陥り詰んでしまいました。

ですが、上記以外のパスワードのリセット方法が用意されています。

結論

docker exec -it docker-api-1 flask reset-password

このコマンドを dify/docker のディレクトリ上で実行するだけです。

詳細

https://docs.dify.ai/getting-started/install-self-hosted/faqs#id-4.-how-to-reset-the-password-of-the-admin-account

Difyの公式サイトにリセット方法が記載されています。

docker exec -it docker-api-1 flask reset-password

これだけでパスワードをCUI上でリセットすることができます。

sample
dify@my-pc:~/hello/dify/docker$ docker compose up -d
[+] Running 9/9
 ✔ Container docker-web-1         Started                                                              0.1s 
 ✔ Container docker-sandbox-1     Started                                                              0.1s 
 ✔ Container docker-db-1          Started                                                              0.1s 
 ✔ Container docker-redis-1       Started                                                              0.1s 
 ✔ Container docker-weaviate-1    Started                                                              0.1s 
 ✔ Container docker-ssrf_proxy-1  Started                                                              0.1s 
 ✔ Container docker-api-1         Started                                                              0.1s 
 ✔ Container docker-worker-1      Started                                                              0.1s 
 ✔ Container docker-nginx-1       Started                                                              0.1s 
dify@my-pc:~/hello/dify/docker$ docker exec -it docker-api-1 flask reset-password
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
sagemaker.config INFO - Not applying SDK defaults from location: /etc/xdg/sagemaker/config.yaml
sagemaker.config INFO - Not applying SDK defaults from location: /root/.config/sagemaker/config.yaml
Email: hello@dify.ai
New password: newpassword4567
Password confirm: newpassword4567
Password reset successfully.

Discussion