0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Rancher Desktop に Dify Community版 を構築してみました

Last updated at Posted at 2025-07-03

概要

ローカル環境に SUSE Rancher Desktop をインストールし、そこに Dify Community版 を構築してみました。その手順となります。

Dify は誰でも簡単にAIアプリケーションを開発できるオープンソースのアプリケーションです。

ローカル環境

  • MacBook Pro 16-inch 2019
  • プロセッサ:2.3GHz 8コア Intel Corei9
  • グラフィックス:Intel UHD Graphics 630 1536MB
  • メモリ:32GB 2667MHz DDR4
  • macOS Sequoia 15.5
  • Rancher Desktop v1.19.3
  • docker 28.1.1-rd
  • dify 1.5.1

構築手順

1. 以下のコマンドを実行して Dify の構築準備をします

## GitからDifyを取得します
$ git clone https://github.com/langgenius/dify.git
Cloning into 'dify'...
remote: Enumerating objects: 179485, done.
remote: Counting objects: 100% (370/370), done.
remote: Compressing objects: 100% (95/95), done.
remote: Total 179485 (delta 324), reused 275 (delta 275), pack-reused 179115 (from 3)
Receiving objects: 100% (179485/179485), 97.96 MiB | 6.03 MiB/s, done.
Resolving deltas: 100% (131396/131396), done.
Updating files: 100% (5701/5701), done.

## dify/docker ディレクトリに移動
$ cd dify/docker

2. docker-compose.yaml の中身を確認します

$ cat docker-compose.yaml
     1	# ==================================================================
     2	# WARNING: This file is auto-generated by generate_docker_compose
     3	# Do not modify this file directly. Instead, update the .env.example
     4	# or docker-compose-template.yaml and regenerate this file.
     5	# ==================================================================
     6	
     7	x-shared-env: &shared-api-worker-env
     8	  CONSOLE_API_URL: ${CONSOLE_API_URL:-}
     9	  CONSOLE_WEB_URL: ${CONSOLE_WEB_URL:-}
    10	  SERVICE_API_URL: ${SERVICE_API_URL:-}
    11	  APP_API_URL: ${APP_API_URL:-}
    12	  APP_WEB_URL: ${APP_WEB_URL:-}
            :
            :
            :
            :

冒頭メッセージにあるように環境ファイルを利用して構築します(必要であれば編集)

## 環境ファイルの作成(コピー作成)
$ cp .env.example .env

3. Rancher Desktopを起動します

$ rdctl start   
INFO[0000] About to launch /usr/bin/open -a /Applications/Rancher Desktop.app ... 

4. dify を構築します。

$ docker compose up -d
WARN[0000] The "DB_PASSWORD" variable is not set. Defaulting to a blank string. 
WARN[0000] The "DB_USERNAME" variable is not set. Defaulting to a blank string. 
WARN[0000] The "DB_DATABASE" variable is not set. Defaulting to a blank string. 
WARN[0000] The "DB_USERNAME" variable is not set. Defaulting to a blank string. 
WARN[0000] The "DB_DATABASE" variable is not set. Defaulting to a blank string. 
WARN[0000] The "DB_PASSWORD" variable is not set. Defaulting to a blank string. 
WARN[0000] The "DB_PASSWORD" variable is not set. Defaulting to a blank string. 
WARN[0000] The "DB_DATABASE" variable is not set. Defaulting to a blank string. 
WARN[0000] The "DB_USERNAME" variable is not set. Defaulting to a blank string. 
WARN[0000] The "CERTBOT_EMAIL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "CERTBOT_DOMAIN" variable is not set. Defaulting to a blank string. 
WARN[0000] The "DB_DATABASE" variable is not set. Defaulting to a blank string. 
WARN[0000] The "DB_USERNAME" variable is not set. Defaulting to a blank string. 
WARN[0000] The "DB_PASSWORD" variable is not set. Defaulting to a blank string. 
[+] Running 81/81
 ✔ api Pulled                                155.5s 
 ✔ ssrf_proxy Pulled                          29.8s 
 ✔ nginx Pulled                               19.3s 
 ✔ db Pulled                                 121.9s 
 ✔ sandbox Pulled                             93.7s 
 ✔ web Pulled                                121.8s 
 ✔ weaviate Pulled                             7.2s 
 ✔ redis Pulled                               63.6s 
 ✔ worker Pulled                             155.5s 
 ✔ plugin_daemon Pulled                      175.5s 
                                   
[+] Running 12/12
 ✔ Network docker_ssrf_proxy_network  Created  0.3s 
 ✔ Network docker_default             Created  0.2s 
 ✔ Container docker-web-1             Created  0.3s 
 ✔ Container docker-redis-1           Created  0.3s 
 ✔ Container docker-db-1              Created  0.3s 
 ✔ Container docker-sandbox-1         Created  0.3s 
 ✔ Container docker-ssrf_proxy-1      Created  0.3s 
 ✔ Container docker-weaviate-1        Created  0.3s 
 ✔ Container docker-plugin_daemon-1   Created  0.1s 
 ✔ Container docker-worker-1          Created  0.1s 
 ✔ Container docker-api-1             Created  0.1s 
 ✔ Container docker-nginx-1           Created  0.0s 
Attaching to api-1, db-1, nginx-1, plugin_daemon-1, redis-1, sandbox-1, ssrf_proxy-1, weaviate-1, web-1, worker-1
sandbox-1        | 2025/06/14 09:07:24 setup.go:29: [INFO]initializing nodejs runner environment...
sandbox-1        | 2025/06/14 09:07:24 setup.go:85: [INFO]nodejs runner environment initialized
sandbox-1        | 2025/06/14 09:07:24 setup.go:33: [INFO]initializing python runner environment...
sandbox-1        | 2025/06/14 09:07:24 config.go:129: [INFO]network has been enabled
sandbox-1        | 2025/06/14 09:07:24 config.go:145: [INFO]using https proxy: http://ssrf_proxy:3128
sandbox-1        | 2025/06/14 09:07:24 config.go:154: [INFO]using http proxy: http://ssrf_proxy:3128
sandbox-1        | 2025/06/14 09:07:24 server.go:20: [INFO]config init success
sandbox-1        | 2025/06/14 09:07:24 server.go:26: [INFO]runner dependencies init success
sandbox-1        | 2025/06/14 09:07:24 cocrrent.go:31: [INFO]setting max requests to 50
sandbox-1        | 2025/06/14 09:07:24 cocrrent.go:13: [INFO]setting max workers to 4
sandbox-1        | 2025/06/14 09:07:24 server.go:47: [INFO]installing python dependencies...
sandbox-1        | 2025/06/14 09:07:24 server.go:53: [INFO]python dependencies installed
sandbox-1        | 2025/06/14 09:07:24 server.go:55: [INFO]initializing python dependencies sandbox...
Gracefully stopping... (press Ctrl+C again to force)
Error response from daemon: error while creating mount source path '/Users/ituru/MyDevelops/RancherDesktop/dify/docker/volumes/redis/data': chown /Users/ituru/MyDevelops/RancherDesktop/dify/docker/volumes/redis/data: permission denied

db領域がうまくマウントできない RancherDesktop側の既知の問題 ようです

RancherDesktop画面にてVirtual Machine の Emulation を「VZ」変更し、Virtual Machine の Volumes を「virtiofs」変更します

再度 Dify を構築します
$ docker compose up -d
[+] Running 10/10
 ✔ Container docker-db-1             Healthy   0.5s 
 ✔ Container docker-redis-1          Running   0.0s 
 ✔ Container docker-ssrf_proxy-1     Running   0.0s 
 ✔ Container docker-web-1            Running   0.0s 
 ✔ Container docker-weaviate-1       Running   0.0s 
 ✔ Container docker-sandbox-1        Running   0.0s 
 ✔ Container docker-api-1            Started   0.6s 
 ✔ Container docker-worker-1         Started   0.6s 
 ✔ Container docker-plugin_daemon-1  Started   0.5s 
 ✔ Container docker-nginx-1          Started   0.3s 

5. Difyのステータスを確認します

$ docker ps -f name=docker --format "table {{.ID}}\t{{.Image}}\t{{.Status}}"
CONTAINER ID   IMAGE                                       STATUS
340915985fea   nginx:latest                                Up 2 minutes
11c542079de9   langgenius/dify-api:1.4.2                   Up 2 minutes
4fbbcc969c62   langgenius/dify-api:1.4.2                   Up 2 minutes
e8dd09d9e0ff   langgenius/dify-plugin-daemon:0.1.2-local   Up 2 minutes
a5a392c06dd1   semitechnologies/weaviate:1.19.0            Up 3 minutes
0ece5def77f0   langgenius/dify-web:1.4.2                   Up 3 minutes
1ab42f14266e   langgenius/dify-sandbox:0.2.12              Up 3 minutes (healthy)
7a6b810d7d32   redis:6-alpine                              Up 3 minutes (healthy)
aae12db7b40b   ubuntu/squid:latest                         Up 3 minutes
af01a04e6e97   postgres:15-alpine                          Up 3 minutes (healthy)

6. dify にアクセスできるか確認します

$ curl http://localhost/install
404 page not found

アクセスできません、、、、、フロントアプリである nginx の起動ポート番号を調べてみます

$ docker port 340915985fea
80/tcp -> 0.0.0.0:80
80/tcp -> [::]:80
443/tcp -> 0.0.0.0:443
443/tcp -> [::]:443

80番ポートを利用している別アプリを調べてみます

## 80番ポートの利用チェック
$ lsof -i:80
COMMAND   PID  USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ssh     18182 ituru   22u  IPv4 0xfcf39e2c6f2004ed      0t0  TCP *:http (LISTEN)

## 上記で取得したPIDでプロセスをgrep
$ ps -axwwo user,pid,ppid,pgid,command | grep 18182
ituru            18182     1 18182 ssh: /Users/ituru/Library/Application Support/rancher-desktop/lima/0/ssh.sock [mux]  

どうやら80番ポートは RancheDesktop で利用しているようです。デフォルトでTraefikがEnableになっているためです

7. 環境設定ファイルの変更(.env ファイルの編集)

以下のように nginx の利用ポート番号を変更します

# ------------------------------
# Docker Compose Service Expose Host Port Configurations
# ------------------------------
# EXPOSE_NGINX_PORT=80
# EXPOSE_NGINX_SSL_PORT=443
EXPOSE_NGINX_PORT=8888
EXPOSE_NGINX_SSL_PORT=8443

8. 再度 Dify を構築します

## 構築
$ docker compose up -d
[+] Running 10/10
 ✔ Container docker-redis-1          Running   0.0s 
 ✔ Container docker-weaviate-1       Running   0.0s 
 ✔ Container docker-ssrf_proxy-1     Running   0.0s 
 ✔ Container docker-db-1             Healthy  12.5s 
 ✔ Container docker-web-1            Running   0.0s 
 ✔ Container docker-sandbox-1        Running   0.0s 
 ✔ Container docker-plugin_daemon-1  Started  13.0s 
 ✔ Container docker-worker-1         Started  13.1s 
 ✔ Container docker-api-1            Started  13.1s 
 ✔ Container docker-nginx-1          Started  12.0s 

## ステータス確認
$ docker ps -f name=docker --format "table {{.ID}}\t{{.Image}}\t{{.Status}}"
CONTAINER ID   IMAGE                                       STATUS
840c1a699d6f   nginx:latest                                Up About a minute
1d81058c9087   langgenius/dify-api:1.4.2                   Up About a minute
1734eca87980   langgenius/dify-api:1.4.2                   Up About a minute
8045d982918e   langgenius/dify-plugin-daemon:0.1.2-local   Up About a minute
a5a392c06dd1   semitechnologies/weaviate:1.19.0            Up 41 minutes
0ece5def77f0   langgenius/dify-web:1.4.2                   Up 41 minutes
1ab42f14266e   langgenius/dify-sandbox:0.2.12              Up 41 minutes (healthy)
7a6b810d7d32   redis:6-alpine                              Up 41 minutes (healthy)
aae12db7b40b   ubuntu/squid:latest                         Up 41 minutes
af01a04e6e97   postgres:15-alpine                          Up 41 minutes (healthy)

## nginx ポート確認
$ docker port 840c1a699d6f
80/tcp -> 0.0.0.0:8888
80/tcp -> [::]:8888
443/tcp -> 0.0.0.0:8443
443/tcp -> [::]:8443

9. 再度 dify にアクセスできるか確認します

$ curl http://localhost:8888/install

コマンドラインでうまくいったようなので、ブラウザで実際にアクセスしてみます。

20250703.dify.install.png

その時に起動しているコンテナ一覧を RancherDesktop で確認してみました。

20250703.rd.containers.dify.png

10. 後処理

Rancher Desktopを停止します

## Dify の停止
$ docker compose down
[+] Running 12/12
 ✔ Container docker-plugin_daemon-1   Removed   10.7s 
 ✔ Container docker-weaviate-1        Removed    0.6s 
 ✔ Container docker-worker-1          Removed    3.8s 
 ✔ Container docker-nginx-1           Removed   10.9s 
 ✔ Container docker-sandbox-1         Removed    0.6s 
 ✔ Container docker-ssrf_proxy-1      Removed   11.1s 
 ✔ Container docker-web-1             Removed   10.3s 
 ✔ Container docker-api-1             Removed    2.0s 
 ✔ Container docker-redis-1           Removed    0.8s 
 ✔ Container docker-db-1              Removed    0.5s 
 ✔ Network docker_default             Removed    1.3s 
 ✔ Network docker_ssrf_proxy_network  Removed    0.4s 

## RancherDesktop の停止
$ rdctl shutdown
Shutting down.

11. おまけ

オープンソースソフトウェアである Dify のアップデート内容を過去にクローンしたDifyに反映させる方法

$ cd dify/docker
$ git pull origin main
$ docker compose down
$ docker compose pull
$ docker compose up -d

まとめ

Rancher Desktop 上で Difyを起動するところまで確認できました。次は実際にDifyを動かしてみようかと思います。

参考記事

Difyコミュニティエディション を Docker 環境へ導入
Dify公式ドキュメント
Dify公式GitHub

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?