Deploy Dify with Docker Compose

Clone Dify

Clone the Dify source code to your local machine:

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

Starting Dify

  1. Navigate to the Docker directory in the Dify source code
cd dify/docker
  1. Copy the environment configuration file
cp .env.example .env
  1. Start the Docker containers Choose the appropriate command to start the containers based on the Docker Compose version on your system. You can use the $ docker compose version command to check the version, and refer to the Docker documentation for more information:
    • If you have Docker Compose V2, use the following command: bash docker compose up -d
    • If you have Docker Compose V1, use the following command: bash docker-compose up -d

After executing the command, you should see output similar to the following, showing the status and port mappings of all containers: Docker Compose output

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            5001/tcp

With these steps, you should be able to install Dify successfully.

Access Dify

Access administrator initialization page to set up the admin account:

# Local environment
http://localhost/install

# Server environment
http://your_server_ip/install

And set your admin account: Set your admin account

After setting up the admin account, you can log in to Dify with your admin account: Login