Dify
Stack
Dify - the LLM application platform: a visual builder for chatbots, agents, and workflows, with built-in RAG, model management, and observability.
Configuration
TypeComposelinuxDB_PASSWORD=''INNER_API_KEY=''PLUGIN_DAEMON_KEY=''QDRANT_API_KEY=''REDIS_AUTH=# openssl rand -hex 24SANDBOX_API_KEY=''SECRET_KEY=''Template by deployable-sh·Source
Report issueServices
api
Configuration
Imagelanggenius/dify-api:1.14.2/app/api/storage : appstorageSECRET_KEY=${SECRET_KEY}DB_USERNAME=postgresDB_PASSWORD=${DB_PASSWORD}DB_HOST=dbDB_PORT=5432DB_DATABASE=difyREDIS_HOST=redisREDIS_PORT=6379REDIS_PASSWORD=${REDIS_AUTH}CELERY_BROKER_URL=redis://:${REDIS_AUTH}@redis:6379/1VECTOR_STORE=qdrantQDRANT_URL=http://vectordb:6333QDRANT_API_KEY=${QDRANT_API_KEY}STORAGE_TYPE=opendalOPENDAL_SCHEME=fsOPENDAL_FS_ROOT=/app/api/storageCODE_EXECUTION_ENDPOINT=http://sandbox:8194CODE_EXECUTION_API_KEY=${SANDBOX_API_KEY}SSRF_PROXY_HTTP_URL=http://ssrf-proxy:3128SSRF_PROXY_HTTPS_URL=http://ssrf-proxy:3128PLUGIN_DAEMON_URL=http://plugin-daemon:5002PLUGIN_DAEMON_KEY=${PLUGIN_DAEMON_KEY}PLUGIN_DIFY_INNER_API_URL=http://api:5001PLUGIN_DIFY_INNER_API_KEY=${INNER_API_KEY}INNER_API_KEY_FOR_PLUGIN=${INNER_API_KEY}MIGRATION_ENABLED=trueMODE=apiunless-stoppedImage details
worker
Configuration
Imagelanggenius/dify-api:1.14.2/app/api/storage : appstorageSECRET_KEY=${SECRET_KEY}DB_USERNAME=postgresDB_PASSWORD=${DB_PASSWORD}DB_HOST=dbDB_PORT=5432DB_DATABASE=difyREDIS_HOST=redisREDIS_PORT=6379REDIS_PASSWORD=${REDIS_AUTH}CELERY_BROKER_URL=redis://:${REDIS_AUTH}@redis:6379/1VECTOR_STORE=qdrantQDRANT_URL=http://vectordb:6333QDRANT_API_KEY=${QDRANT_API_KEY}STORAGE_TYPE=opendalOPENDAL_SCHEME=fsOPENDAL_FS_ROOT=/app/api/storageCODE_EXECUTION_ENDPOINT=http://sandbox:8194CODE_EXECUTION_API_KEY=${SANDBOX_API_KEY}SSRF_PROXY_HTTP_URL=http://ssrf-proxy:3128SSRF_PROXY_HTTPS_URL=http://ssrf-proxy:3128PLUGIN_DAEMON_URL=http://plugin-daemon:5002PLUGIN_DAEMON_KEY=${PLUGIN_DAEMON_KEY}PLUGIN_DIFY_INNER_API_URL=http://api:5001PLUGIN_DIFY_INNER_API_KEY=${INNER_API_KEY}INNER_API_KEY_FOR_PLUGIN=${INNER_API_KEY}MIGRATION_ENABLED=trueMODE=workerunless-stoppedImage details
worker_beat
Configuration
Imagelanggenius/dify-api:1.14.2SECRET_KEY=${SECRET_KEY}DB_USERNAME=postgresDB_PASSWORD=${DB_PASSWORD}DB_HOST=dbDB_PORT=5432DB_DATABASE=difyREDIS_HOST=redisREDIS_PORT=6379REDIS_PASSWORD=${REDIS_AUTH}CELERY_BROKER_URL=redis://:${REDIS_AUTH}@redis:6379/1VECTOR_STORE=qdrantQDRANT_URL=http://vectordb:6333QDRANT_API_KEY=${QDRANT_API_KEY}STORAGE_TYPE=opendalOPENDAL_SCHEME=fsOPENDAL_FS_ROOT=/app/api/storageCODE_EXECUTION_ENDPOINT=http://sandbox:8194CODE_EXECUTION_API_KEY=${SANDBOX_API_KEY}SSRF_PROXY_HTTP_URL=http://ssrf-proxy:3128SSRF_PROXY_HTTPS_URL=http://ssrf-proxy:3128PLUGIN_DAEMON_URL=http://plugin-daemon:5002PLUGIN_DAEMON_KEY=${PLUGIN_DAEMON_KEY}PLUGIN_DIFY_INNER_API_URL=http://api:5001PLUGIN_DIFY_INNER_API_KEY=${INNER_API_KEY}INNER_API_KEY_FOR_PLUGIN=${INNER_API_KEY}MIGRATION_ENABLED=trueMODE=beatunless-stoppedImage details
web
Configuration
Imagelanggenius/dify-web:1.14.2CONSOLE_API_URL=APP_API_URL=unless-stoppedImage details
plugin_daemon
Configuration
Imagelanggenius/dify-plugin-daemon:0.4.1-local/app/storage : pluginstorageDB_USERNAME=postgresDB_PASSWORD=${DB_PASSWORD}DB_HOST=dbDB_PORT=5432DB_DATABASE=dify_pluginREDIS_HOST=redisREDIS_PORT=6379REDIS_PASSWORD=${REDIS_AUTH}SERVER_PORT=5002SERVER_KEY=${PLUGIN_DAEMON_KEY}DIFY_INNER_API_URL=http://api:5001DIFY_INNER_API_KEY=${INNER_API_KEY}PLUGIN_WORKING_PATH=/app/storage/cwdPLUGIN_REMOTE_INSTALLING_HOST=0.0.0.0PLUGIN_REMOTE_INSTALLING_PORT=5003PLUGIN_REMOTE_INSTALLING_ENABLED=trueunless-stoppedImage details
sandbox
Configuration
Imagelanggenius/dify-sandbox:0.2.12API_KEY=${SANDBOX_API_KEY}GIN_MODE=releaseWORKER_TIMEOUT=15ENABLE_NETWORK=trueHTTP_PROXY=http://ssrf-proxy:3128HTTPS_PROXY=http://ssrf-proxy:3128unless-stoppedImage details
ssrf_proxy
Configuration
Restartunless-stopped./ssrf-proxyentry
Configuration
Ports5000:5000unless-stopped./entryredis
Configuration
Env varsREDIS_AUTH=${REDIS_AUTH}unless-stopped./redisdb
Configuration
Volumes/var/lib/postgresql/data : dbdataPOSTGRES_PASSWORD=${DB_PASSWORD}POSTGRES_DB=difyPGDATA=/var/lib/postgresql/data/pgdataunless-stopped./dbvectordb
Configuration
Imageqdrant/qdrant:v1.18.3/qdrant/storage : qdrantdataQDRANT__SERVICE__API_KEY=${QDRANT_API_KEY}unless-stoppedImage details
Standalone Install
Select an install method, to see config/commands for deploying Dify
Install on Portainer
Import all app templates into your Portainer instance, for easy 1-click deploys
- Ensure both Docker and Portainer are installed, and up-to-date
- Log into your Portainer web UI
- Under Settings → App Templates, paste the below URL
- Head to Home → App Templates, and the list of apps will show up
- Select Dify, fill in any config options, and hit Deploy
Template Import URL
https://raw.githubusercontent.com/Lissy93/portainer-templates/main/templates.json
Show Me
Original stackfile
The compose file this template deploys, straight from its repo:
name: dify
x-api-env: &api-env
SECRET_KEY: ${SECRET_KEY}
DB_USERNAME: postgres
DB_PASSWORD: ${DB_PASSWORD}
DB_HOST: db
DB_PORT: "5432"
DB_DATABASE: dify
REDIS_HOST: redis
REDIS_PORT: "6379"
REDIS_PASSWORD: ${REDIS_AUTH}
CELERY_BROKER_URL: redis://:${REDIS_AUTH}@redis:6379/1
VECTOR_STORE: qdrant
QDRANT_URL: http://vectordb:6333
QDRANT_API_KEY: ${QDRANT_API_KEY}
STORAGE_TYPE: opendal
OPENDAL_SCHEME: fs
OPENDAL_FS_ROOT: /app/api/storage
CODE_EXECUTION_ENDPOINT: http://sandbox:8194
CODE_EXECUTION_API_KEY: ${SANDBOX_API_KEY}
SSRF_PROXY_HTTP_URL: http://ssrf-proxy:3128
SSRF_PROXY_HTTPS_URL: http://ssrf-proxy:3128
PLUGIN_DAEMON_URL: http://plugin-daemon:5002
PLUGIN_DAEMON_KEY: ${PLUGIN_DAEMON_KEY}
PLUGIN_DIFY_INNER_API_URL: http://api:5001
PLUGIN_DIFY_INNER_API_KEY: ${INNER_API_KEY}
INNER_API_KEY_FOR_PLUGIN: ${INNER_API_KEY}
MIGRATION_ENABLED: "true"
services:
api:
image: langgenius/dify-api:1.14.2
restart: unless-stopped
environment:
<<: *api-env
MODE: api
volumes:
- appstorage:/app/api/storage
depends_on: [db, redis, vectordb]
worker:
image: langgenius/dify-api:1.14.2
restart: unless-stopped
environment:
<<: *api-env
MODE: worker
volumes:
- appstorage:/app/api/storage
depends_on: [db, redis, vectordb]
worker_beat:
image: langgenius/dify-api:1.14.2
restart: unless-stopped
environment:
<<: *api-env
MODE: beat
depends_on: [db, redis]
web:
image: langgenius/dify-web:1.14.2
restart: unless-stopped
environment:
CONSOLE_API_URL: ""
APP_API_URL: ""
plugin_daemon:
image: langgenius/dify-plugin-daemon:0.4.1-local
restart: unless-stopped
environment:
DB_USERNAME: postgres
DB_PASSWORD: ${DB_PASSWORD}
DB_HOST: db
DB_PORT: "5432"
DB_DATABASE: dify_plugin
REDIS_HOST: redis
REDIS_PORT: "6379"
REDIS_PASSWORD: ${REDIS_AUTH}
SERVER_PORT: "5002"
SERVER_KEY: ${PLUGIN_DAEMON_KEY}
DIFY_INNER_API_URL: http://api:5001
DIFY_INNER_API_KEY: ${INNER_API_KEY}
PLUGIN_WORKING_PATH: /app/storage/cwd
PLUGIN_REMOTE_INSTALLING_HOST: "0.0.0.0"
PLUGIN_REMOTE_INSTALLING_PORT: "5003"
PLUGIN_REMOTE_INSTALLING_ENABLED: "true"
volumes:
- pluginstorage:/app/storage
depends_on: [db, redis]
sandbox:
image: langgenius/dify-sandbox:0.2.12
restart: unless-stopped
environment:
API_KEY: ${SANDBOX_API_KEY}
GIN_MODE: release
WORKER_TIMEOUT: "15"
ENABLE_NETWORK: "true"
HTTP_PROXY: http://ssrf-proxy:3128
HTTPS_PROXY: http://ssrf-proxy:3128
ssrf_proxy:
build: ./ssrf-proxy
restart: unless-stopped
entry:
build: ./entry
restart: unless-stopped
ports:
- "5000:5000"
depends_on: [api, web]
redis:
build: ./redis
restart: unless-stopped
environment:
REDIS_AUTH: ${REDIS_AUTH}
db:
build: ./db
restart: unless-stopped
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: dify
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- dbdata:/var/lib/postgresql/data
vectordb:
image: qdrant/qdrant:v1.18.3
restart: unless-stopped
environment:
QDRANT__SERVICE__API_KEY: ${QDRANT_API_KEY}
volumes:
- qdrantdata:/qdrant/storage
volumes:
appstorage:
pluginstorage:
dbdata:
qdrantdata:
Or deploy it directly from the source:
git clone https://github.com/deployable-sh/stacks
cd stacks
docker compose -f dify/compose.yaml up -dMore install options in our documentation.
Container Documentation
api Documentation
The Dify.AI Backend Docker Image.
worker Documentation
The Dify.AI Backend Docker Image.
worker_beat Documentation
The Dify.AI Backend Docker Image.
web Documentation
The Dify.AI Frontend Docker Image.
sandbox Documentation
vectordb Documentation
Qdrant - vector similarity search engine with extended filtering support
Serve Dify on your own domain behind Caddy, Nginx or Traefik. Fill in your domain and copy the result. It's a starting point, some apps need their own base URL or extra headers set too.
Proxying dify.example.com to http://entry:5000
Add this to your Caddyfile
dify.example.com {
reverse_proxy http://entry:5000
}Check the logs first
Nine times out of ten the logs tell you exactly what went wrong.
- In Portainer, go to Containers, click the container, then Logs. Or run
docker logs <container> - Exit codes help too:
137means killed, usually out of memory.126or127means the command inside the image is broken.
Port already in use
If deployment fails with "Bind for 0.0.0.0:5000 failed: port is already allocated", something else on your server is using that port.
- Find what's using it:
sudo ss -tlnp | grep :5000 - Stop the other service, or pick a different host port. In
5000:5000only the left number is yours to change, the right one belongs to the app.
Running but the page won't load
The container is up but nothing appears in your browser.
- Use your server's real IP:
http://your-server-ip:5000. The 0.0.0.0 link Portainer shows isn't a real address. - Give it a minute after first deploy, dify can take a while to initialise.
- Make sure your firewall allows the port, e.g.
sudo ufw allow 5000
Image won't pull
Test the pull directly on the host: docker pull langgenius/dify-api:1.14.2
- "manifest unknown" means the tag no longer exists.
- "toomanyrequests" is the Docker Hub rate limit. Log in with
docker loginto raise it. - "no space left on device" means a full disk. Reclaim space with
docker system prune
"exec format error"
This means the image was built for a different CPU architecture than your server.
- Check yours with
uname -m: x86_64 is amd64, aarch64 is arm64. Raspberry Pi and other ARM boards are the usual culprits.
Container keeps restarting
The unless-stopped restart policy relaunches the app after every crash, so the real error can scroll past.
- Check the logs right after a restart, the last few lines before it died are the useful ones.
- Get the exit code with
docker inspect <container> --format '{{.State.ExitCode}}' - Still stuck? Redeploy once with the restart policy set to
noso the failure stays visible.
Required settings are blank
CONSOLE_API_URL, APP_API_URL have no default value, and dify may crash or misbehave if left empty.
- Fill them in on the deploy screen before hitting deploy.
Stack won't deploy
Compose stacks fail fast on small mistakes, and Portainer shows the reason just above the editor.
- YAML only accepts spaces for indentation, a single tab breaks the whole file.
Raise an issue
Found something which isn't working as it should? Here's how to report it.
- Bug within the app: Open an issue within dify's repo
- Template not working: Open an issue on deployable-sh/stacks
- This website not working: Open an issue on lissy93/portainer-templates
A Compose stack
Dify is a Compose stack, a set of containers (11 of them) defined in one file and brought up together by Portainer, then started and stopped as a single app.
The services
This stack is built from 11 containers that run side by side. Here's each one, with the image it runs and anything it waits for first:
apirunslanggenius/dify-api:1.14.2, starts after db, redis, vectordbworkerrunslanggenius/dify-api:1.14.2, starts after db, redis, vectordbworker_beatrunslanggenius/dify-api:1.14.2, starts after db, rediswebrunslanggenius/dify-web:1.14.2plugin_daemonrunslanggenius/dify-plugin-daemon:0.4.1-local, starts after db, redissandboxrunslanggenius/dify-sandbox:0.2.12ssrf_proxyentry, starts after api, webredisdbvectordbrunsqdrant/qdrant:v1.18.3
Ports
A port is the door the app answers on. A mapping like 5000:5000 means it's reachable on port 5000 of your server, where the left number is yours to change and the right one belongs to the app. It opens:
5000:5000
Volumes
A volume is where Dify keeps its files so they survive an update or a restart. Without one, anything it saves would sit inside the container and vanish the moment it's recreated. This template mounts:
/app/api/storagekept in theappstoragevolume Docker manages/app/storagekept in thepluginstoragevolume Docker manages/var/lib/postgresql/datakept in thedbdatavolume Docker manages/qdrant/storagekept in theqdrantdatavolume Docker manages
Environment variables
Environment variables are the settings you hand over when you deploy, things like a password or a timezone. Dify takes 48 of them, and 2 need a value before it'll start properly:
SECRET_KEY, pulled from your own environmentDB_USERNAME, defaults topostgresDB_PASSWORD, pulled from your own environmentDB_HOST, defaults todbDB_PORT, defaults to5432DB_DATABASE, defaults todify_pluginREDIS_HOST, defaults toredisREDIS_PORT, defaults to6379REDIS_PASSWORD, pulled from your own environmentCELERY_BROKER_URL, defaults toredis://:REDIS_AUTH@redis:6379/1VECTOR_STORE, defaults toqdrantQDRANT_URL, defaults tohttp://vectordb:6333QDRANT_API_KEY, pulled from your own environmentSTORAGE_TYPE, defaults toopendalOPENDAL_SCHEME, defaults tofsOPENDAL_FS_ROOT, defaults to/app/api/storageCODE_EXECUTION_ENDPOINT, defaults tohttp://sandbox:8194CODE_EXECUTION_API_KEY, pulled from your own environmentSSRF_PROXY_HTTP_URL, defaults tohttp://ssrf-proxy:3128SSRF_PROXY_HTTPS_URL, defaults tohttp://ssrf-proxy:3128PLUGIN_DAEMON_URL, defaults tohttp://plugin-daemon:5002PLUGIN_DAEMON_KEY, pulled from your own environmentPLUGIN_DIFY_INNER_API_URL, defaults tohttp://api:5001PLUGIN_DIFY_INNER_API_KEY, pulled from your own environmentINNER_API_KEY_FOR_PLUGIN, pulled from your own environmentMIGRATION_ENABLED, defaults totrueMODE, defaults tobeatCONSOLE_API_URL, needs a valueAPP_API_URL, needs a valueSERVER_PORT, defaults to5002SERVER_KEY, pulled from your own environmentDIFY_INNER_API_URL, defaults tohttp://api:5001DIFY_INNER_API_KEY, pulled from your own environmentPLUGIN_WORKING_PATH, defaults to/app/storage/cwdPLUGIN_REMOTE_INSTALLING_HOST, defaults to0.0.0.0PLUGIN_REMOTE_INSTALLING_PORT, defaults to5003PLUGIN_REMOTE_INSTALLING_ENABLED, defaults totrueAPI_KEY, pulled from your own environmentGIN_MODE, defaults toreleaseWORKER_TIMEOUT, defaults to15ENABLE_NETWORK, defaults totrueHTTP_PROXY, defaults tohttp://ssrf-proxy:3128HTTPS_PROXY, defaults tohttp://ssrf-proxy:3128REDIS_AUTH, pulled from your own environmentPOSTGRES_PASSWORD, pulled from your own environmentPOSTGRES_DB, defaults todifyPGDATA, defaults to/var/lib/postgresql/data/pgdataQDRANT__SERVICE__API_KEY, pulled from your own environment
Restart policy
The restart policy here is unless-stopped, so Docker restarts Dify after a crash or reboot, but leaves it off when you stop it on purpose. You can change this on the deploy screen. The choices are no (never restart), on-failure (only after a crash), unless-stopped (restart unless you stop it), and always (bring it back no matter what).
Networking
Portainer puts these services on one shared private network, so they can find each other by name (like api) while only the ports above are open to you.
Platform
The platform is linux, the kind of system the container is built to run on. Docker and Portainer handle this on a normal Linux server.
Portainer app templates
Zooming out, this whole page comes from a Portainer app template: a short recipe telling Portainer how to set Dify up. Add the template list to Portainer once, then deploying Dify is a click rather than a wall of config.