Deploy Dify with Docker Compose: A Production-minded Guide

Install Dify with its official Docker Compose workflow, verify the services, protect the installation screen and prepare a reverse proxy before exposing it publicly.

What you are building

Dify is an open-source platform for building AI applications, workflows, agents and retrieval-augmented generation services. This guide follows the official Docker Compose path and adds the checks needed before a public launch.

Before you begin

  • Use a supported Linux distribution and a user that can run Docker.
  • Point a domain to the server before configuring HTTPS.
  • Keep model-provider API keys outside source control.
  • Dify documents a minimum of 2 CPU cores and 4 GiB of RAM. Real workloads may need more memory because the stack includes several services.

Deployment plan

The official repository contains the Compose configuration under the docker directory. Copy the example environment file, review secrets and exposed ports, start the stack, then finish setup through the installation page.

Production checks

  • Do not leave the initial installation route unattended on a public IP.
  • Put Caddy or another reverse proxy in front of Dify and enable HTTPS.
  • Back up the database, uploaded files and the environment configuration.
  • Monitor disk usage and container health before adding users.
  • Start with a small test workload and scale after observing memory use.

Sources and next steps

Review the official Dify repository for current commands and release notes. Compare a suitable AI application server plan before deployment.

Environment and requirements

  • Operating system: 64-bit Linux with Docker and Docker Compose
  • CPU: 2 cores minimum; 4 cores recommended
  • Memory: 4 GiB minimum; 8 GiB recommended for a small team
  • Storage: 40 GiB SSD minimum plus backup capacity
  • Network: Domain, HTTPS and outbound model API access

Step 1: Install Docker and verify Compose

Install Docker from the official Docker documentation for your distribution. Confirm both the engine and Compose plugin are available.

bash
docker --version
docker compose version

Expected result: The command completes without an error and the described service or file is available.

Step 2: Clone the official Dify repository

Clone the repository and enter the Docker deployment directory. Review the release or tag you intend to operate before going live.

bash
git clone https://github.com/langgenius/dify.git
cd dify/docker

Expected result: The command completes without an error and the described service or file is available.

Step 3: Create and review the environment file

Copy the provided example. Replace default secrets, confirm URLs and keep the resulting file out of public repositories.

bash
cp .env.example .env
chmod 600 .env

Expected result: The command completes without an error and the described service or file is available.

Step 4: Start the application stack

Start the services in detached mode, then review container status and recent logs before opening the setup page.

bash
docker compose up -d
docker compose ps
docker compose logs --tail=100

Expected result: The command completes without an error and the described service or file is available.

Step 5: Complete setup and add HTTPS

Open the documented installation route, create the first administrator, then place the service behind Caddy. Restrict direct access to internal service ports.

bash
# Example Caddy target
# dify.example.com {
#   reverse_proxy 127.0.0.1:80
# }

Expected result: The command completes without an error and the described service or file is available.

RELATED SERVER OPTIONS

Only if you need hosting

These options match the scenario in this guide. Verify current price and specifications before buying; AIOOS may earn a commission at no extra cost to you.

RainYun

RainYun Los Angeles 4 vCPU / 8 GB

Contextual hosting option; verify current price and workload fit before purchase.

4 vCPU · 8 GB · 30 GB system disk
Check current offer
RESOURCES I USE · REFERRAL

Two services to compare when you are ready to launch

This is not an automated ranking, and neither service is necessary for everyone. These are services I use, with the use case and limitations kept visible.

Cloud server · Used for early projects

RainYun

A practical candidate for a website or small service. Choose by user region, configuration and measured workload rather than the lowest headline price.

Referral disclosure: these links contain my referral information. I may receive a platform benefit if you sign up or order, at no additional charge from AIOOS. Check the order page for current pricing, availability, regions and terms. Read the full affiliate disclosure