docker/README.md
Welcome to the new docker directory for deploying Dify using Docker Compose. This README outlines the updates, deployment instructions, and migration details for existing users.
Certbot Container: docker-compose.yaml now contains certbot for managing SSL certificates. This container automatically renews certificates and ensures secure HTTPS connections.
For more information, refer docker/certbot/README.md.
Persistent Environment Variables: Essential startup defaults are provided in .env.example, while local values are stored in .env, ensuring that your configurations persist across deployments.
What is
.env? </br> </br> The.envfile is the local startup file. Copy it from.env.examplefor a default deployment. Optional advanced settings live inenvs/*.env.examplefiles.
Unified Vector Database Services: All vector database services are now managed from a single Docker Compose file docker-compose.yaml. You can switch between different vector databases by setting the VECTOR_STORE environment variable in your .env file.
docker-compose.yamlPrerequisites: Ensure Docker and Docker Compose are installed on your system.
Environment Setup:
docker directory..env.example to .env..env when you need to change essential startup defaults. Copy optional files from envs/ without the .example suffix when you need advanced settings..env file copied from .env.example, you may use the environment synchronization tool to keep it aligned with the latest .env.example updates while preserving your custom settings.
See the Environment Variables Synchronization section below.Running the Services:
docker compose up -d from the docker directory to start the services.VECTOR_STORE variable in your .env file to your desired vector database service, such as milvus, weaviate, or opensearch.cp .env.example .env
docker compose up -d
SSL Certificate Setup:
docker/certbot/README.md to set up SSL certificates using Certbot.OpenTelemetry Collector Setup:
ENABLE_OTEL to true in .env.OTLP_BASE_ENDPOINT properly.docker-compose.middleware.yaml for setting up essential middleware services like databases and caches.docker directory.middleware.env file is created by running cp envs/middleware.env.example middleware.env (refer to the envs/middleware.env.example file).docker directory.docker compose --env-file middleware.env -f docker-compose.middleware.yaml -p dify up -d to start PostgreSQL/MySQL (per DB_TYPE) plus the bundled Weaviate instance.Compose automatically loads
COMPOSE_PROFILES=${DB_TYPE:-postgresql},weaviatefrommiddleware.env, so no extra--profileflags are needed. Adjust variables inmiddleware.envif you want a different combination of services.
For users migrating from the docker-legacy setup:
.env configuration and Docker Compose setup.docker-compose.yaml, ssrf_proxy/squid.conf, or nginx/conf.d/default.conf, you will need to reflect these changes in the .env file you create..env, .env.example, and envs/.env.example contains the essential default configuration for Docker Compose deployments..env contains local startup values copied from .env.example and any local changes.envs/*.env.example files contain optional advanced configuration grouped by theme.Docker Compose reads envs/*.env files when present, then reads .env last so values in .env take precedence.
VECTOR_STORE), users can set specific endpoints, ports, and authentication details.STORAGE_TYPE), users can configure specific settings for S3, Azure Blob, Google Storage, etc.The root .env.example file contains the essential startup settings. Optional and provider-specific settings are grouped in envs/*.env.example files. Here are some of the key sections and variables:
Common Variables:
CONSOLE_API_URL, SERVICE_API_URL: URLs for different API services.APP_WEB_URL: Frontend application URL.FILES_URL: Base URL for file downloads and previews.Server Configuration:
LOG_LEVEL, DEBUG, FLASK_DEBUG: Logging and debug settings.SECRET_KEY: A key for signing sessions, JWTs, and file URLs. Leave it empty to let Dify generate a persistent key in the storage directory, or set a unique value yourself.Database Configuration:
DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT, DB_DATABASE: PostgreSQL database credentials and connection details.Redis Configuration:
REDIS_HOST, REDIS_PORT, REDIS_PASSWORD: Redis server connection settings.REDIS_KEY_PREFIX: Optional global namespace prefix for Redis keys, topics, streams, and Celery Redis transport artifacts.Celery Configuration:
CELERY_BROKER_URL: Configuration for Celery message broker.Storage Configuration:
STORAGE_TYPE, OPENDAL_SCHEME, OPENDAL_FS_ROOT: Default local file storage settings. Optional storage backends are configured from the files under envs/.Vector Database Configuration:
VECTOR_STORE: Type of vector database (e.g., weaviate, milvus).WEAVIATE_ENDPOINT, MILVUS_URI.CORS Configuration:
WEB_API_CORS_ALLOW_ORIGINS, CONSOLE_CORS_ALLOW_ORIGINS: Settings for cross-origin resource sharing.OpenTelemetry Configuration:
ENABLE_OTEL: Enable OpenTelemetry collector in api.OTLP_BASE_ENDPOINT: Endpoint for your OTLP exporter.Other Service-Specific Environment Variables:
nginx, redis, db, and vector databases have specific environment variables that are directly referenced in the docker-compose.yaml.When upgrading Dify or pulling the latest changes, new environment variables may be introduced in .env.example or the optional files under envs/.
If you use the default workflow, review .env.example and keep your .env aligned with essential startup values.
If you maintain a customized .env file copied from .env.example, an optional environment variables synchronization tool is provided.
This tool performs a one-way synchronization from
.env.exampleto.env. Existing values in.envare never overwritten automatically.
dify-env-sync.sh (Optional)This script compares your current .env file with the latest .env.example template and helps safely apply new or updated environment variables.
What it does
.env file before making any changes.env.example.env.env.example for reviewBackup behavior
Before synchronization, the current .env file is saved to the env-backup/ directory with a timestamped filename
(e.g. env-backup/.env.backup_20231218_143022).
When to use
.env file.env.example has been updated with new environment variables.env file copied from .env.exampleUsage
# Grant execution permission (first time only)
chmod +x dify-env-sync.sh
# Run the synchronization
./dify-env-sync.sh
.env.example file and the Docker Compose configuration files in the docker directory.This README aims to guide you through the deployment process using the new Docker Compose setup. For any issues or further assistance, please refer to the official documentation or contact support.