linux 安装docker并部署Dify

环境:腾讯云 Centos9 Stream
1.安装docker
yum install docker
#yum install docker 失败
Error: Error downloading packages:
  netavark-2:1.15.1-1.el9.x86_64: Cannot download, all mirrors were already tried without success

#Update and Clean Yum Cache
sudo yum clean all
sudo yum makecache
sudo yum update

#Try Alternative Repositories
sudo dnf install epel-release
sudo dnf config-manager --set-enabled crb

#Manually Download the Package
wget https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/netavark-1.15.1-1.el9.x86_64.rpm
sudo dnf install ./netavark-1.15.1-1.el9.x86_64.rpm

#Check for Package Availability
sudo dnf search netavark

再次执行yum install docker 成功

2. 查看是否存在podman-compose 如不存在则安装
pip3 install podman-compose

3.下载dify源码
可通过git下载 或直接 download源码
wget https://github.com/langgenius/dify/archive/refs/heads/main.zip

按照官方文档,进到dify/docker 目录 
podman-compose up -d

如果能正常下载镜像资源,等待即可

如果linux服务器无法正常下载docker镜像,可考虑以下方法

4.加载本地镜像
在能正常下载docker镜像的机器上将镜像另存为tar,可以在windows上开代理下载
docker images
如下
REPOSITORY                      TAG           IMAGE ID       CREATED        SIZE
langgenius/dify-api             1.1.3         ed2e405efefe   3 months ago   2.82GB
langgenius/dify-web             1.1.3         35890b3c1965   3 months ago   721MB
langgenius/dify-sandbox         0.2.11        9692656f3121   3 months ago   821MB
langgenius/dify-plugin-daemon   0.0.6-local   4002e2998008   3 months ago   1.94GB
ubuntu/squid                    latest        0769de994018   3 months ago   358MB
postgres                        15-alpine     ef9d1517df69   4 months ago   391MB
nginx                           latest        124b44bfc9cc   4 months ago   279MB
redis                           6-alpine      148bb5411c18   5 months ago   44.6MB
semitechnologies/weaviate       1.19.0        17a5238fcfc3   2 years ago    74.3MB

将镜像另存
docker save -o dify-api.tar langgenius/dify-api:1.1.3
docker save -o dify-web.tar langgenius/dify-web:1.1.3
docker save -o dify-sandbox.tar langgenius/dify-sandbox:0.2.11
docker save -o dify-plugin-daemon.tar langgenius/dify-plugin-daemon:0.0.6-local
docker save -o squid.tar ubuntu/squid:latest
docker save -o postgres.tar postgres:15-alpine
docker save -o nginx.tar nginx:latest
docker save -o redis.tar redis:6-alpine
docker save -o weaviate.tar semitechnologies/weaviate:1.19.0

传输镜像 
可使用scp或xftp将镜像上传至linux服务器

在要部署的linux服务器上加载镜像
docker load -i dify-api.tar
docker load -i dify-web.tar
docker load -i dify-sandbox.tar
docker load -i dify-plugin-daemon.tar
docker load -i squid.tar
docker load -i postgres.tar
docker load -i nginx.tar
docker load -i redis.tar
docker load -i weaviate.tar

5.启动容器
#启动dify容器
podman-compose up -d

正常情况下应直接加载本地已load的image,如果提示需重新下载镜像,大概率是load的镜像与docker-compose.yaml中的版本号不一致,可重新下载最新版本镜像或修改yaml中的版本号

#修改版本号后 重启成功

#如果启动失败,报错已启动同名镜像,可自行停止
podman-compose down

6.访问dify页面  ip为公网ip
http://xx.xx.xx.xx/apps

启动成功后如果无法访问 可能是端口限制
1.检查安全组是否开放端口
2.检查防火墙是否有限制
sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT
或 关闭防火墙
sudo iptables -F

再次访问成功

你可能感兴趣的:(linux,docker,运维)