Centos7.9中使用Docker安裝云崽機器人
前面我寫了如何普通版搭建云崽教程,今天我們來使用docker來安裝,感謝docker鏡像源作者:如青桑(QQ: 1666633887)
普通版教程:https://blog.hanhanz.top/?p=309
鏡像源地址:https://hub.docker.com/r/moeta233/yunzai-chatgpt
Ubuntu版docker安裝云崽教程:https://err0r.top/article/Yunzai-chatgptPlugin/
使用docker的前提是你得有docker,怎么看你是否已經安裝了呢,在終端輸入docker version ,如果提示未找到命令,那就是沒安裝,如果有輸出內容,那就太棒啦,你可以跳過安裝docker部分啦~請前往下方安裝云崽部分
前提條件
Docker要求系統為64位、Linux系統內核版本為3.8以上
cat /etc/redhat-release
uname -r

參考我的系統是Centos7.9,內核版本為3.10,是64位的,
安裝Docker
安裝軟體包
yum install -y yum-utils device-mapper-persistent-data lvm2
設定yum源
#二選一,也可以不選
yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo(中央倉庫)
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo(阿里倉庫)
docker的版本選擇和安裝
-
查看版本
yum list docker-ce --showduplicates | sort -r
這里我選擇安裝第一個23.0.1的版本
-
選擇好版本進行安裝
yum -y install docker-ce-23.0.1
不報錯就說明安裝好了
-
啟動docker
systemctl start docker -
檢查已安裝的docker
docker version
-
設定開機自啟
systemctl enable docker
安裝云崽
上面我們安裝好了docker,現在可以安裝云崽了
鏡像介紹
一個開箱即用的云崽Bot,集成鍋巴插件和
ChatGPT插件,已配置好所有依賴和
ffmpeg,默認用戶:root,密碼:password,請務必在連接后使用
passwd root,更改root賬戶的密碼,
使用方法
請直接運行:
docker run -it -p {SSH埠}:22 -p {鍋巴埠}:50831 --name {容器名稱} moeta233/yunzai-chatgpt
例如:
docker run -it -p 22:22 -p 50831:50831 --name yunzai moeta233/yunzai-chatgpt
國內鏡像
鏡像較大,建議使用國內鏡像:registry.cn-beijing.aliyuncs.com/moeta/yunzai-chatgpt
docker run -it -p 22:22 -p 50831:50831 --name yunzai registry.cn-beijing.aliyuncs.com/moeta/yunzai-chatgpt
運行之后先是會拉取鏡像,一切正常的話,會提示你配置QQ號還有密碼以及登錄協議主人QQ等配置項,登錄成功后會出現下面界面,這樣就算成功了,在QQ聊天界面給機器人發送#重啟就可以后臺運行了,配置ChatGPT插件的話,私聊機器人#鍋巴登錄去鍋巴里面進行配置,當然如果你是大神或者你就要自己配置,請參考我的另一篇教程:https://blog.hanhanz.top/?p=309


后臺運行的方法
-
第一種
發送重啟后,直接
Ctrl+P+Q就退出docker了,后臺也會繼續運行 -
第二種
這種方法適用于你的QQ號登錄沒有出現問題的時候
發送重啟后,會出現下面界面,然后輸入
exit退出docker,然后發送docker start yunzai命令運行剛剛創建的docker容器,如果要查看日志的話,輸入docker attach yunzai進入查看(只能查看attach以后的日志,我本人docker小白,不太懂docker,可能也有其他方法,可以指正)

教程到這結束了,
其他問題
當云崽退出后會進入bash命令列,因此可能不支持意外退出自動重啟,但容器開啟會自動運行,您可以在 /app/yunzai.sh 自定義啟動腳本,
如果您初次配置出現問題,可以洗掉容器重建,或重新啟動容器并立刻附加,以容器名yunzai為例:
Linux:
docker start yunzai && docker attach yunzai
Windows Powershell:
docker start yunzai; docker attach yunzai
Dockerfile
FROM node:bullseye
VOLUME ["/app"]
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list && mkdir -p /app
WORKDIR /app
RUN apt-get update && apt-get install -y curl wget vim git cmake redis-server dialog openssh-server ssh vim
RUN echo "root:password" | chpasswd \
&& sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config \
&& sed -i 's/^#\(PermitRootLogin.*\)/\1/' /etc/ssh/sshd_config \
&& /etc/init.d/ssh start
EXPOSE 22
RUN npm install pnpm --registry=https://registry.npm.taobao.org -g
RUN git clone --depth=1 -b main https://gitee.com/yoimiya-kokomi/Yunzai-Bot.git
WORKDIR /app/Yunzai-Bot
RUN pnpm install -P
RUN git clone --depth=1 https://gitee.com/guoba-yunzai/guoba-plugin.git ./plugins/Guoba-Plugin/
RUN pnpm install --filter=guoba-plugin
EXPOSE 50831
RUN git clone --depth=1 https://gitee.com/ikechan/chatgpt-plugin.git ./plugins/chatgpt-plugin/
WORKDIR /app/Yunzai-Bot/plugins/chatgpt-plugin
RUN pnpm install
RUN apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 \
libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libgbm-dev libnss3 \
ca-certificates fonts-liberation lsb-release xdg-utils wget ttf-wqy-zenhei
RUN fc-cache -fv
WORKDIR /usr/share/
ADD https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz /usr/share/
RUN tar -xf /usr/share/ffmpeg-release-amd64-static.tar.xz \
&& mv /usr/share/ffmpeg-6.0-amd64-static /usr/share/ffmpeg \
&& rm -rf /usr/share/ffmpeg-release-amd64-static.tar.xz \
&& chmod 755 /usr/share/ffmpeg/ffmpeg \
&& chmod 755 /usr/share/ffmpeg/ffprobe \
&& ln -s /usr/share/ffmpeg/ffmpeg /usr/bin/ffmpeg \
&& ln -s /usr/share/ffmpeg/ffprobe /usr/bin/ffprobe \
&& chmod 755 /usr/bin/ffmpeg \
&& chmod 755 /usr/bin/ffprobe
WORKDIR /app/Yunzai-Bot
COPY ./yunzai.sh /app/yunzai.sh
ENTRYPOINT [ "/app/yunzai.sh" ]
啟動腳本 yunzai.sh
#!/bin/bash
service ssh start
echo -e "\033[0;96m登錄后您可以在QQ發送 #重啟 命令使Bot轉入后臺,進入終端,\033[0m"
cd "/app/Yunzai-Bot" || exit
node app
bash
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/548221.html
標籤:其他
上一篇:python面試題匯總
