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, things like chatbots, document assistants and multi-step workflows, in a visual editor that runs in your browser. Here I will walk through running the free Community Edition on your own Windows PC or Mac with Docker Compose, what it actually costs you, and what the licence lets you do and what it doesn’t.
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, which I explain below.
What Dify actually is
The project calls Dify an “open-source LLM app development platform”. An LLM, or large language model, is the kind of AI that sits behind chat assistants. What Dify gives you is a dashboard where you design what the AI should do, so you are not writing all the plumbing yourself.
Here is what the README lists as the main features:
- Workflow: build and test AI workflows on a visual canvas.
- Model support: the project says it works with hundreds of models from dozens of providers, including any OpenAI API-compatible model and self-hosted ones.
- Prompt IDE: write prompts and compare how different models answer.
- RAG pipeline: RAG means the AI answers from your own documents. Dify can extract text from PDFs, PPTs and other common formats.
- Agent: agents that run commands, install software and handle files inside their own sandbox (an isolated container).
- LLMOps: logs and performance monitoring for your apps.
- Backend-as-a-Service: everything you build also gets an API, so your own website or program can call it.
| Way to use Dify | Who runs it | Cost |
|---|---|---|
| Dify Cloud | The Dify company hosts it | See the project’s pricing page |
| Community Edition (this guide) | You, on your own computer or server | Free software; you pay your model provider |
| Dify Enterprise | Organisations needing SSO and support | Arranged with the company |
What you need
- CPU: at least 2 cores. RAM: at least 4 GiB. These are the minimums in the README; give it more memory and it feels a lot happier.
- Docker and Docker Compose v2.24.0 or later. Docker runs software in isolated boxes called containers. Compose starts many containers together.
- Git, or a ZIP download of the repository from GitHub.
- A decent internet connection for the first start. Docker pulls images for Dify’s API and web app, PostgreSQL, Redis, Weaviate, Nginx, a sandbox, a plugin daemon and more. The repository does not state the total download size.
- An API key from a model provider, or a model running on your own machine. This is the part that can cost money.
No GPU is needed for Dify itself. You only need a strong machine if you also want to run the AI model locally.
What the Dify licence allows
The repository uses the “Dify Open Source License”, which is Apache 2.0 with a few extra conditions bolted on. In plain words:
- Commercial use is allowed, including using Dify as the backend of your own application or as an internal platform in a company.
- No multi-tenant service without permission. You may not use the Dify source code to run a multi-tenant environment unless Dify authorises it in writing. The licence defines one tenant as one workspace. If you want to do this, you need a commercial licence.
- Keep the logo and copyright. If you use Dify’s frontend (the
web/folder or the “web” Docker image), you may not remove or change the logo or copyright information in the console or apps. This does not apply if you don’t use the frontend. - Contributors agree the company can make the licence stricter or looser later, and can use contributed code commercially.
- The licence also notes that the product’s interactive design is protected by an appearance patent.
For personal use on your own computer, none of this gets in your way. If you are planning to resell Dify to clients as a hosted service, go read the LICENSE file yourself and ask the company. This is a summary, not legal advice.
Things to sort out before you install
- Use the real repository. Clone only from github.com/langgenius/dify.
- The sample passwords are public.
.env.exampleships withDB_PASSWORD=difyai123456,REDIS_PASSWORD=difyai123456, a fixedWEAVIATE_API_KEY,PLUGIN_DAEMON_KEYandSANDBOX_API_KEY=dify-sandbox. The file itself marksDIFY_AGENT_API_TOKENandDIFY_AGENT_SERVER_SECRET_KEYas 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 insideCELERY_BROKER_URL, so change both together. - It listens on port 80. The Nginx container publishes ports
80and443on your computer, and the plugin debugging port5003is 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. - Create the admin account straight away. The first person to open the install page sets up the admin account.
- 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.
- It contacts Dify’s servers. The defaults include
CHECK_UPDATE_URL=https://updates.dify.aiandMARKETPLACE_ENABLED=true(the plugin marketplace). Install only plugins you trust. - Your secrets live in two places. Settings are in
docker/.env. Uploaded files and databases are indocker/volumes/. Don’t share or publish either. - Agents and code nodes run code. They run inside sandbox containers, and
SANDBOX_ENABLE_NETWORK=trueby default, so they can reach the internet through a proxy. Think about 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.
- Install Docker from docs.docker.com/get-docker (the link the README uses), start it and wait until it says it is running.
- Open PowerShell and download the project:
git clone https://github.com/langgenius/dify.git
- Run the README’s four commands, one line at a time:
cd dify cd docker cp .env.example .env docker compose up -d
- Now wait. The first run downloads every image and can take a while on a slow connection.
In PowerShell, cp is a built-in shortcut for copying a file. The old Command Prompt doesn’t have it, so stick with PowerShell.
How to install Dify on Mac
- Install Docker from docs.docker.com/get-docker and start it.
- Open Terminal (Cmd + Space, type Terminal).
- Run:
git clone https://github.com/langgenius/dify.git cd dify cd docker cp .env.example .env docker compose up -d
The same commands work on Linux too. The repository doesn’t say anything specific about Apple Silicon or Intel Macs.
First use: create your admin account
- Open
http://localhost/installin your browser. This kicks off what the README calls the initialization process. - Create the admin account with a strong, unique password.
- 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.
- Create your first app and send a test message.
The repository doesn’t describe the exact screens, so just 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.
| Setting | Default | What it does |
|---|---|---|
EXPOSE_NGINX_PORT | 80 | The port you open in the browser. Change it if port 80 is busy. |
EXPOSE_NGINX_SSL_PORT | 443 | The HTTPS port. |
SECRET_KEY | empty | Left empty, Dify generates a persistent key in its storage folder. |
DB_PASSWORD | difyai123456 | PostgreSQL password. Change it for anything beyond testing. |
VECTOR_STORE | weaviate | The vector database used for document search. Others include milvus and opensearch. |
DB_TYPE | postgresql | The main database type. |
NGINX_CLIENT_MAX_BODY_SIZE | 100M | Largest upload Nginx accepts. |
NGINX_HTTPS_ENABLED | false | Turns 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 doesn’t give a full update command list. It does provide a helper for your settings file. After you pull a newer version, new settings may show up in .env.example. This script adds them to your .env, keeps your own values, and saves a backup first 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 doesn’t explain how to run it. Copy the docker/volumes/ folder somewhere safe before any update.
The project doesn’t 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
| Problem | What to try |
|---|---|
docker compose gives an error about the file format | Check your version. The project requires Docker Compose v2.24.0 or later. |
| Port 80 is already in use | Set 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 Windows | You are in Command Prompt. Use PowerShell. |
| The page does not load right after starting | Give the containers a few minutes. The database is set up on first start. |
| Computer becomes very slow | 4 GiB RAM is the stated minimum. Close other apps or give Docker more memory. |
| A workflow cannot reach an address on your own network | Private addresses are blocked by default. See SSRF_PROXY_ALLOW_PRIVATE_IPS in .env. |
| The app works but the AI gives no answer | No 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

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.

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.

FastMCP for beginners
Turn a plain Python function into a tool an AI assistant can call. Setup on Windows and Mac, step by step.

Set up Context Mode the easy way
Context Mode is an MCP plugin that stops your coding agent's context window from filling up with raw tool output.

TradingView MCP Guide
Self-host the free TradingView MCP server on Windows or Mac, or pay for hosting — and mind the data-not-advice caveat.

AWS MCP servers, explained
AWS publishes a big set of open-source MCP servers. Here's what they do and how to wire one into your AI coding assistant.

MCP servers in TypeScript
A beginner-friendly look at mcp-use for building and connecting MCP servers, clients and agents in TypeScript.

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.