ubuntu如何部署Dify以及安装Docker

一. 安装Docker

(1)打开ubuntu终端,执行命令:

sudo apt update
sudo apt upgrade

(2) 允许APT使用通过HTTPS来传输仓库:

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

(3)添加Docker的官方GPG密钥:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

 (4)添加Docker的稳定仓库:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

 注:此时可能报如下错误

解决办法:替换为清华大学镜像

        (1)创建或编辑 Docker 源文件:

sudo gedit /etc/apt/sources.list.d/docker.list

        (2)添加清华源:

deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu focal stable

        (3)保存,退出

(5)使用命令更新 Ubuntu 源列表:

sudo apt-get update

(6)安装 Docker:

sudo apt-get install docker-ce docker-ce-cli containerd.io

(7)验证是否安装成功:

docker --version

 

(8)确认 Docker 服务是否正常运行:

sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker

 出现这个即代表Docker部署成功,此时我们尝试拉取容器:

sudo docker run hello-world

大概率会报如下错误,这是由于连接Docker官方镜像仓库受阻

解决办法 :

        (1)找到 Docker 的配置文件:

sudo gedit /etc/docker/daemon.json

        (2)添加国内镜像加速器:(这里不确定现在哪些能用,所以都加进去了)

{ 
    "registry-mirrors": [
    "https://docker.mirrors.ustc.edu.cn",
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com",
    "https://mirror.ccs.tencentyun.com",
    "https://hub.littlediary.cn",
    "https://hub.xdark.top",
    "https://docker.org",
    "https://docker.linkedbus.com",
    "https://docker.xuanyuan.me",
    "https://github.com/Daocloud/public-image-mirror",
    "https://docker.hpcloud.cloud",
    "https://docker.m.daocloud.io",
    "https://docker.unsee.tech",
    "https://docker.1panel.live",
    "http://mirrors.ustc.edu.cn",
    "https://docker.chenby.cn",
    "http://mirror.azure.cn",
    "https://dockerpull.org",
    "https://dockerhub.icu",
    "https://www.kelen.cc/dry/docker-hub-mirror",
    "https://docker.mrxn.net/",
    "https://dislabaiot.xyz/"
  ]
}

        (3)保存,退出

        (4)重启Docker服务

sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl status docker

        (5)重新尝试拉取容器

sudo docker run hello-world

如上,拉取成功。

我这里还出现了执行Docker命令时,报错:permission denied while trying to connect to the Docker daemon socket,这个问题表明当前用户没有权限访问 Docker 的守护进程/var/run/docker.sock)。通常在安装 Docker 后,非 root 用户需要被添加到 docker 用户组以获得正确的权限。你可以尝试以下步骤来解决该问题:

        (1)运行以下命令来检查当前用户是否已被添加到 docker 组:

groups

        如果没有看到 docker 组,表示你需要将用户添加到该组:

sudo usermod -aG docker $USER

        (2)重新登陆运行代码:groups,查看是否成功添加,如果没有的话需要重启电脑。成功加进去的话应该可以解决这个问题。

二. 部署Dify(这需要你完成Docker的安装)

(1)从github克隆 Dify 源代码到本地:

git clone https://github.com/langgenius/dify.git

 (2)启动Dify:

cd dify/docker
cp .env.example .env
docker compose up -d

 出现这个问题说明没有启动Docker(前提是你成功安装了),此时我们只需:

        启动Docker:

sudo systemctl start docker

        再启动docker compose服务即可成功 

docker compose up -d

(3)在浏览器输入http://localhost即可访问Dify 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值