Ubuntu20.04部署Dify(Docker方式)
- Ubuntu20.04 Dify
- Install Docker
- Install Docker Compose
- Run Dify
- Running Ollama
由于写这篇博客的时候电脑还没装输入法,所以先用半吊子英文顶着了…关于最后运行ollama的部分可以无视,因为我修改了端口所以才需要这么运行。
Ubuntu20.04 Dify
Install Docker
sudo apt update
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.iosudo systemctl status docker
docker version
Install Docker Compose
version: 2.33.1
sudo curl -L "https://github.com/docker/compose/releases/download/v2.33.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
Run Dify
git clone https://github.com/langgenius/dify.git
cd docker
cp .env.example .env
sudo docker compose up -d
problem:
Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
solution:
sudo gedit /etc/docker/daemon.json
and add:
{"registry-mirrors": ["https://docker.1ms.run","https://docker.xuanyuan.me"]
}
sudo systemctl daemon-reload
sudo systemctl restart docker
url: http://localhost/install
Running Ollama
I changed the port and found something…
this is my ollama service config file:
[Unit]
Description=Ollama Service
After=network-online.target[Service]
ExecStart=/usr/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=$PATH"
Environment="OLLAMA_HOST=0.0.0.0:11451"
OLLAMA_SCHED_SPREAD=1[Install]
WantedBy=default.target
I need to run ollama like this:OLLAMA_HOST=127.0.0.1:11451 ollama run qwq
, it works, but why???
Reference:
- 如何在 Ubuntu 20.04 上安装和使用 Docker
- 最新2025年docker 出现无法拉取docker: Error response from daemon: Get “https://registry-1.docker.io/v2/”: net/等问题
- Docker/DockerHub 国内镜像源/加速列表(3月6日更新-长期维护)