Deploy with Docker Compose

Prerequisites

Operating SystemSoftwareExplanation

macOS 10.14 or later

Docker Desktop

Set the Docker virtual machine (VM) to use a minimum of 2 virtual CPUs (vCPUs) and 8 GB of initial memory. Otherwise, the installation may fail. For more information, please refer to the Docker Desktop installation guide for Mac.

Linux platforms

Docker 19.03 or later Docker Compose 1.25.1 or later

Please refer to the Docker installation guide and the Docker Compose installation guide for more information on how to install Docker and Docker Compose, respectively.

Windows with WSL 2 enabled

Docker Desktop

We recommend storing the source code and other data that is bound to Linux containers in the Linux file system rather than the Windows file system. For more information, please refer to the Docker Desktop installation guide for using the WSL 2 backend on Windows.

[!IMPORTANT]

Dify 0.6.12 has introduced significant enhancements to Docker Compose deployment, designed to improve your setup and update experience. For more information, read the README.md.

Clone Dify

Clone the Dify source code to your local machine:

git clone https://github.com/langgenius/dify.git

Start Dify

Navigate to the docker directory in the Dify source code and execute the following command to start Dify:

cd dify/docker
cp .env.example .env
docker compose up -d

If your system has Docker Compose V2 installed instead of V1, use docker compose instead of docker-compose. Check if this is the case by running $ docker compose version. Read more information here.

Deployment Results:

[+] Running 11/11
  Network docker_ssrf_proxy_network  Created                                                                 0.1s 
  Network docker_default             Created                                                                 0.0s 
  Container docker-redis-1           Started                                                                 2.4s 
  Container docker-ssrf_proxy-1      Started                                                                 2.8s 
  Container docker-sandbox-1         Started                                                                 2.7s 
  Container docker-web-1             Started                                                                 2.7s 
  Container docker-weaviate-1        Started                                                                 2.4s 
  Container docker-db-1              Started                                                                 2.7s 
  Container docker-api-1             Started                                                                 6.5s 
  Container docker-worker-1          Started                                                                 6.4s 
  Container docker-nginx-1           Started                                                                 7.1s

Finally, check if all containers are running successfully:

docker compose ps

This includes 3 core services: api / worker / web, and 6 dependent components: weaviate / db / redis / nginx / ssrf_proxy / sandbox .

NAME                  IMAGE                              COMMAND                   SERVICE      CREATED              STATUS                        PORTS
docker-api-1          langgenius/dify-api:0.6.13         "/bin/bash /entrypoi…"   api          About a minute ago   Up About a minute             5001/tcp
docker-db-1           postgres:15-alpine                 "docker-entrypoint.s…"   db           About a minute ago   Up About a minute (healthy)   5432/tcp
docker-nginx-1        nginx:latest                       "sh -c 'cp /docker-e…"   nginx        About a minute ago   Up About a minute             0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp
docker-redis-1        redis:6-alpine                     "docker-entrypoint.s…"   redis        About a minute ago   Up About a minute (healthy)   6379/tcp
docker-sandbox-1      langgenius/dify-sandbox:0.2.1      "/main"                   sandbox      About a minute ago   Up About a minute             
docker-ssrf_proxy-1   ubuntu/squid:latest                "sh -c 'cp /docker-e…"   ssrf_proxy   About a minute ago   Up About a minute             3128/tcp
docker-weaviate-1     semitechnologies/weaviate:1.19.0   "/bin/weaviate --hos…"   weaviate     About a minute ago   Up About a minute             
docker-web-1          langgenius/dify-web:0.6.13         "/bin/sh ./entrypoin…"   web          About a minute ago   Up About a minute             3000/tcp
docker-worker-1       langgenius/dify-api:0.6.13         "/bin/bash /entrypoi…"   worker       About a minute ago   Up About a minute             5001/tcp

Upgrade Dify

Enter the docker directory of the dify source code and execute the following commands:

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

Access Dify

Finally, access http://localhost/install to use the deployed Dify.

Customize Dify

Edit the environment variable values in your .env file directly. Then, restart Dify with:

docker compose down
docker compose up -d

The full set of annotated environment variables along can be found under docker/.env.example.

Last updated