> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dify.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Docker Compose で Dify をデプロイする

> このドキュメントは AI によって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/self-host/deploy/quick-start/docker-compose) を参照してください。

<Tip>
  一般的なデプロイの問題は [FAQ](/ja/self-host/deploy/quick-start/faqs) を参照してください。
</Tip>

## デプロイ前の準備

マシンが以下の最小システム要件を満たしているか確認してください。

### ハードウェア

* CPU >= 2 コア
* RAM >= 4 GiB

### ソフトウェア

| オペレーティングシステム    | 必要なソフトウェア                               | 備考                                                                                                                                                               |
| :-------------- | :-------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| macOS 10.14 以降  | Docker Desktop / Docker Compose 2.24.0+ | 2 vCPU 以上、8 GiB 以上のメモリを割り当てます。<br /><br />[Mac 用 Docker Desktop のインストール](https://docs.docker.com/desktop/mac/install/) を参照してください。                                |
| Linux           | Docker 19.03+ / Docker Compose 2.24.0+  | 手順は以下を参照してください。<br /><br />[Docker Engine のインストール](https://docs.docker.com/engine/install/) / [Docker Compose のインストール](https://docs.docker.com/compose/install/) |
| Windows (WSL 2) | Docker Desktop / Docker Compose 2.24.0+ | ソースコードとデータは Linux ファイルシステムに保存。<br /><br />[Windows 用 Docker Desktop のインストール](https://docs.docker.com/desktop/windows/install/#wsl-2-backend) を参照してください。          |

## デプロイと起動

<Steps>
  <Step title="Dify をクローン">
    Dify のソースコードをローカルマシンにクローンします。

    ```bash theme={null}
    git clone --branch "$(curl -s https://api.github.com/repos/langgenius/dify/releases/latest | jq -r .tag_name)" https://github.com/langgenius/dify.git
    ```
  </Step>

  <Step title="Dify を起動">
    1. Dify ソースコード内の `docker` ディレクトリに移動します：

       ```bash theme={null}
       cd dify/docker
       ```

    2. 必須の環境設定ファイルをコピーします：

       ```bash theme={null}
       cp .env.example .env
       ```

       後でデプロイをカスタマイズする場合は [カスタマイズ](#カスタマイズ) を参照してください。

    3. コンテナを起動します：

           <Note>
             Dify は Docker Compose 2.24.0 以降を必要とします。`docker compose version` を実行してバージョンを確認してください。
           </Note>

       ```bash theme={null}
       docker compose up -d
       ```

       以下のコンテナが起動します：

       * 5 つのコアサービス：`api`、`worker`、`worker_beat`、`web`、`plugin_daemon`
       * 6 つの依存コンポーネント：`weaviate`、`db_postgres`、`redis`、`nginx`、`ssrf_proxy`、`sandbox`

       各コンテナのステータスと起動時間を示す以下のような出力が表示されます：

       ```bash theme={null}
       [+] Running 13/13
       ✔ Network docker_ssrf_proxy_network  Created                                                                10.0s 
       ✔ Network docker_default             Created                                                                 0.1s 
       ✔ Container docker-sandbox-1         Started                                                                 0.3s 
       ✔ Container docker-db_postgres-1     Healthy                                                                 2.8s 
       ✔ Container docker-web-1             Started                                                                 0.3s 
       ✔ Container docker-redis-1           Started                                                                 0.3s 
       ✔ Container docker-ssrf_proxy-1      Started                                                                 0.4s 
       ✔ Container docker-weaviate-1        Started                                                                 0.3s 
       ✔ Container docker-worker_beat-1     Started                                                                 3.2s 
       ✔ Container docker-api-1             Started                                                                 3.2s 
       ✔ Container docker-worker-1          Started                                                                 3.2s 
       ✔ Container docker-plugin_daemon-1   Started                                                                 3.2s 
       ✔ Container docker-nginx-1           Started                                                                 3.4s 
       ```

    4. すべてのコンテナが正常に動作しているか確認します：

       ```bash theme={null}
       docker compose ps
       ```

       各コンテナのステータスが `Up` または `healthy` となっている、以下のような出力が表示されます：

       ```bash theme={null}
       NAME                     IMAGE                                       COMMAND                  SERVICE         CREATED          STATUS                             PORTS
       docker-api-1             langgenius/dify-api:1.10.1                  "/bin/bash /entrypoi…"   api             26 seconds ago   Up 22 seconds                      5001/tcp
       docker-db_postgres-1     postgres:15-alpine                          "docker-entrypoint.s…"   db_postgres     26 seconds ago   Up 25 seconds (healthy)            5432/tcp
       docker-nginx-1           nginx:latest                                "sh -c 'cp /docker-e…"   nginx           26 seconds ago   Up 22 seconds                      0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp
       docker-plugin_daemon-1   langgenius/dify-plugin-daemon:0.4.1-local   "/bin/bash -c /app/e…"   plugin_daemon   26 seconds ago   Up 22 seconds                      0.0.0.0:5003->5003/tcp, :::5003->5003/tcp
       docker-redis-1           redis:6-alpine                              "docker-entrypoint.s…"   redis           26 seconds ago   Up 25 seconds (health: starting)   6379/tcp
       docker-sandbox-1         langgenius/dify-sandbox:0.2.12              "/main"                  sandbox         26 seconds ago   Up 25 seconds (health: starting)   
       docker-ssrf_proxy-1      ubuntu/squid:latest                         "sh -c 'cp /docker-e…"   ssrf_proxy      26 seconds ago   Up 25 seconds                      3128/tcp
       docker-weaviate-1        semitechnologies/weaviate:1.27.0            "/bin/weaviate --hos…"   weaviate        26 seconds ago   Up 25 seconds                      
       docker-web-1             langgenius/dify-web:1.10.1                  "/bin/sh ./entrypoin…"   web             26 seconds ago   Up 25 seconds                      3000/tcp
       docker-worker-1          langgenius/dify-api:1.10.1                  "/bin/bash /entrypoi…"   worker          26 seconds ago   Up 22 seconds                      5001/tcp
       docker-worker_beat-1     langgenius/dify-api:1.10.1                  "/bin/bash /entrypoi…"   worker_beat     26 seconds ago   Up 22 seconds                      5001/tcp
       ```
  </Step>
</Steps>

## アクセス

1. 管理者初期化ページを開いて、管理者アカウントを設定します：

   ```bash theme={null}
   # ローカル環境
   http://localhost/install

   # サーバー環境
   http://your_server_ip/install
   ```

2. 管理者アカウントの設定が完了したら、以下のアドレスで Dify にログインします：

   ```bash theme={null}
   # ローカル環境
   http://localhost  

   # サーバー環境
   http://your_server_ip
   ```

## カスタマイズ

デプロイをカスタマイズするには、関連するファイルの環境変数を編集してから Dify を再起動します。

<Steps>
  <Step title="環境変数を編集">
    * **必須の起動値** は `docker/.env` にあります（デプロイ時に `docker/.env.example` からコピーして作成したファイル）。直接編集します。

    * **オプションまたはプロバイダー固有の設定** は `docker/envs/` にテンプレートとして用意されています。デフォルト値を上書きするには、対応するテンプレートをコピーし（`.example` 拡張子を外す）、コピーを編集します。

      例：

      ```bash theme={null}
      cd dify/docker
      cp envs/vectorstores/milvus.env.example envs/vectorstores/milvus.env
      ```

    `docker/.env` の値は、`docker/envs/*.env` ファイルの値より優先されます。

    <Tip>
      すべての変数の説明は [環境変数](/ja/self-host/deploy/configuration/environments) を参照してください。
    </Tip>
  </Step>

  <Step title="Dify を再起動">
    ```bash theme={null}
    docker compose down
    docker compose up -d
    ```
  </Step>
</Steps>

## アップグレード

アップグレード手順はリリースによって異なる場合があります。[Releases](https://github.com/langgenius/dify/releases) ページで提供されている対象バージョンのアップグレードガイドを参照してください。

<Note>
  アップグレード後、各 `.env.example` を対応する `.env` と比較し、新規または変更された変数を確認してください。
</Note>
