Dify: How to Self-Host It With Docker Compose on Windows and Mac

By Shah Rukh, software developer · · 8 min read

Dify is an open-source platform for building AI apps, such as chatbots, document assistants and multi-step workflows, in a visual editor in your browser. This guide shows how to run the free Community Edition on your own Windows PC or Mac with Docker Compose, what it really costs, and what the licence does and does not allow.

Read this first. Dify is free to self-host, but it does not include an AI model. You connect your own model provider, and most cloud providers charge for API use. Dify also runs as a group of more than ten Docker containers, so it is heavier than a normal desktop app. And its licence is not plain Apache 2.0: it has extra conditions, explained below.

What Dify is

The project describes Dify as an “open-source LLM app development platform”. An LLM (large language model) is the kind of AI behind chat assistants. Dify gives you a dashboard where you design what the AI should do, instead of writing all the code yourself.

The README lists these main features:

Way to use DifyWho runs itCost
Dify CloudThe Dify company hosts itSee the project’s pricing page
Community Edition (this guide)You, on your own computer or serverFree software; you pay your model provider
Dify EnterpriseOrganisations needing SSO and supportArranged with the company

What you need

No GPU is needed for Dify itself. You only need a strong machine if you also run the AI model locally.

What the Dify licence allows

The repository uses the “Dify Open Source License”, which is Apache 2.0 with additional conditions. In plain words:

For personal use on your own computer, none of these get in your way. If you plan to resell Dify to clients as a hosted service, read the LICENSE file yourself and ask the company. This is a summary, not legal advice.

Precautions before you install

  1. Use the real repository. Clone only from github.com/langgenius/dify.
  2. The sample passwords are public. .env.example ships with DB_PASSWORD=difyai123456, REDIS_PASSWORD=difyai123456, a fixed WEAVIATE_API_KEY, PLUGIN_DAEMON_KEY and SANDBOX_API_KEY=dify-sandbox. The file itself marks DIFY_AGENT_API_TOKEN and DIFY_AGENT_SERVER_SECRET_KEY as development defaults to replace in production. Fine for a test on your laptop; change them before anyone else can reach the machine. Note the Redis password also appears inside CELERY_BROKER_URL, so change both together.
  3. It listens on port 80. The Nginx container publishes ports 80 and 443 on your computer, and the plugin debugging port 5003 is published too. On shared Wi-Fi, other devices may be able to open your Dify login page. Keep your firewall on and don’t forward these ports from your router.
  4. Create the admin account straight away. The first person to open the install page sets up the admin account.
  5. Your data goes to the model provider. Prompts and the document text used to answer them are sent to whichever provider you connect. Don’t upload client or private files unless that provider’s terms suit you, or use a local model.
  6. It contacts Dify’s servers. The defaults include CHECK_UPDATE_URL=https://updates.dify.ai and MARKETPLACE_ENABLED=true (the plugin marketplace). Install only plugins you trust.
  7. Your secrets live in two places. Settings are in docker/.env. Uploaded files and databases are in docker/volumes/. Don’t share or publish either.
  8. Agents and code nodes run code. They run inside sandbox containers, and SANDBOX_ENABLE_NETWORK=true by default, so they can reach the internet through a proxy. Review what you ask an agent to do.

How to install Dify on Windows

The repository gives one set of commands and no Windows-specific steps. They work in PowerShell once Docker is installed.

  1. Install Docker from docs.docker.com/get-docker (the link the README uses), start it and wait until it says it is running.
  2. Open PowerShell and download the project:
    git clone https://github.com/langgenius/dify.git
  3. Run the README’s four commands, one line at a time:
    cd dify
    cd docker
    cp .env.example .env
    docker compose up -d
  4. Wait. The first run downloads every image and can take a long time on a slow connection.

In PowerShell, cp is a built-in shortcut for copying a file. In the old Command Prompt it does not exist, so use PowerShell.

How to install Dify on Mac

  1. Install Docker from docs.docker.com/get-docker and start it.
  2. Open Terminal (Cmd + Space, type Terminal).
  3. Run:
    git clone https://github.com/langgenius/dify.git
    cd dify
    cd docker
    cp .env.example .env
    docker compose up -d

The same commands apply on Linux. The repository does not say anything specific about Apple Silicon or Intel Macs.

First use: create your admin account

  1. Open http://localhost/install in your browser. This starts what the README calls the initialization process.
  2. Create the admin account with a strong, unique password.
  3. Log in and add a model provider in the settings. Paste your API key there. The README links a full list of supported providers in the official documentation.
  4. Create your first app and send a test message.

The exact screens are not described in the repository, so follow what you see on the page.

Useful settings in the .env file

Edit docker/.env, then run docker compose up -d again from the docker folder to apply changes.

SettingDefaultWhat it does
EXPOSE_NGINX_PORT80The port you open in the browser. Change it if port 80 is busy.
EXPOSE_NGINX_SSL_PORT443The HTTPS port.
SECRET_KEYemptyLeft empty, Dify generates a persistent key in its storage folder.
DB_PASSWORDdifyai123456PostgreSQL password. Change it for anything beyond testing.
VECTOR_STOREweaviateThe vector database used for document search. Others include milvus and opensearch.
DB_TYPEpostgresqlThe main database type.
NGINX_CLIENT_MAX_BODY_SIZE100MLargest upload Nginx accepts.
NGINX_HTTPS_ENABLEDfalseTurns on HTTPS. The repo has a Certbot guide in docker/certbot/README.md.

Optional advanced settings live in the docker/envs/ folder. Copy one of its .env.example files next to itself without the .example ending to use it. Values in docker/.env win over those files.

How to update Dify, and what about uninstalling

The repository does not give a full update command list. It does provide a helper for your settings file. After pulling a newer version, new settings may appear in .env.example. This script adds them to your .env, keeps your own values, and first saves a backup in env-backup/:

chmod +x dify-env-sync.sh
./dify-env-sync.sh

It is a shell script, so it suits Mac and Linux. There is also a dify-env-sync.py file in the same folder, but the README does not explain how to run it. Copy the docker/volumes/ folder somewhere safe before any update.

The project does not document an uninstall. You can stop and delete the containers from the Docker app’s own window. Your data stays in docker/volumes/ until you delete that folder.

Common problems

ProblemWhat to try
docker compose gives an error about the file formatCheck your version. The project requires Docker Compose v2.24.0 or later.
Port 80 is already in useSet EXPOSE_NGINX_PORT to another number in .env, run docker compose up -d again and add that port to the address.
cp is not recognised on WindowsYou are in Command Prompt. Use PowerShell.
The page does not load right after startingGive the containers a few minutes. The database is set up on first start.
Computer becomes very slow4 GiB RAM is the stated minimum. Close other apps or give Docker more memory.
A workflow cannot reach an address on your own networkPrivate addresses are blocked by default. See SSRF_PROXY_ALLOW_PRIVATE_IPS in .env.
The app works but the AI gives no answerNo model provider is connected, or the API key is wrong or out of credit.

For anything else, the README points to the official FAQ and to GitHub Discussions.

This guide is based on the project’s repository as it was on October 2, 2026, when the Docker files used Dify version 1.17.1. The project changes often, so if a step looks different, follow the README on GitHub. ToolsCloset is not connected to the project or to LangGenius, Inc.

Frequently asked questions

Is Dify free?

The Community Edition is free to download and run on your own computer. You still pay for whatever AI model provider you connect, unless you run a model locally. Dify Cloud and Dify Enterprise are separate offerings with their own pricing.

Is Dify really open source?

The code is public, under the Dify Open Source License. That is Apache 2.0 with extra conditions: you may not run a multi-tenant service without written permission, and you may not remove the logo or copyright information from the frontend.

Can I use Dify for my business?

Yes. The licence allows commercial use, including as a backend for your own app or as an internal company platform. You need a commercial licence if you want to run a multi-tenant service, where one tenant means one workspace, or remove the Dify logo and copyright from the frontend.

What are the minimum requirements for Dify?

The README states at least 2 CPU cores and 4 GiB of RAM, plus Docker and Docker Compose v2.24.0 or later.

Does Dify work on Windows?

The repository does not give Windows-specific steps, but it runs through Docker, and the same four commands work in PowerShell once Docker is installed and running.

Do I need an OpenAI API key to use Dify?

You need some model to connect, but it does not have to be OpenAI. The project says it supports hundreds of models from dozens of providers, including self-hosted models and any OpenAI API-compatible model.

Is it safe to leave Dify running with the default settings?

For a short test on your own computer, yes. The sample .env file contains publicly known database, Redis and service passwords, and Dify publishes port 80 on your machine, so change those values and keep a firewall on before letting other people or the internet reach it.

More AI tips

🤖

EmailOSINT Review and Guide

See which accounts, data breaches and stolen-password logs are tied to your email, and what to do about each result.

🤖

Free Claude Code Setup Guide

Run the Claude Code app with free AI models on Windows or Mac. Full steps, plus the precautions most guides skip.

🤖

OpenHands Agent Canvas Guide

Set up the OpenHands control centre for AI coding agents on Windows or Mac, with the safety steps to take first.

🤖

LibreChat Docker Setup Guide

Run your own ChatGPT-style chat app on your computer with Docker. Full steps, real costs and safety checks.

🤖

Unity MCP Setup Guide

Let Claude Code, Cursor or Copilot work inside the Unity Editor. Full install steps, plus the precautions to take first.

🤖

sprite-gen Setup Guide

Turn one character drawing into a transparent game sprite sheet. Setup steps, real costs and precautions.

🤖

Logo Design Skill Setup Guide

Add a free logo-design skill to Claude or another AI agent on Windows or Mac, with the precautions to take first.

🤖

Openvid Screen Demo Guide

Record your screen and turn it into a polished demo in the browser, or run Openvid yourself on Windows or Mac.

🤖

ReelMimic Setup Guide

Set up ReelMimic to make an original 2D animation in the style of a reference video, with the copyright checks to do first.

Related tools

🔑

Password Generator

Strong random passwords with a strength meter.

⬇️

Markdown to HTML

Convert Markdown to clean HTML with live preview.

🧾

CSV to JSON

Convert CSV or spreadsheet data to JSON.