Ubuntu 24.04安装docker并部署docker下的微信


前言

官方源暂无法下载docker、采用阿里云源安装;
由于腾讯没有适配Ubuntu下的微信,同时不同版本ubuntu环境依赖不同,使用wine版本windows程序依赖无法解决,故部署docker版微信来使用。

如果有更好的方式或简便的方法请留言!谢谢


一、安装docker

1.添加更新源(此处为阿里云源)

cp /etc/apt/sources.list /etc/apt/sources.list.bak

cat <<EOF >/etc/apt/sources.list
deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
EOF

sudo apt-get update

2.安装所需软件包、添加Docker阿里云仓库及GPG密钥

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

curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu noble stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

3.安装最新版本的Docker CE、将普通用户添加进docker组

sudo apt-get update
sudo apt install docker-ce
sudo systemctl status docker
sudo groupadd -f -r docker
sudo usermod -aG docker ${USER}

二、安装docker版本wechat

1.拉镜像、创建容器微信启动脚本

docker pull bestwu/wechat

cat <<EOF >wechat.sh
#!/bin/bash
HOME=/home/zycheng
# 检查 DISPLAY 变量
if [ -z "$DISPLAY" ]; then
    echo "DISPLAY 环境变量未设置"
    exit 1
fi

# 获取 AUDIO_GID
AUDIO_GID=$(getent group audio | cut -d: -f3)
if [ -z "$AUDIO_GID" ]; then
    echo "无法获取 audio 组的 GID"
    exit 1
fi

# 获取 GID 和 UID
USER_GID=$(id -g)
USER_UID=$(id -u)

# 检查 wechat 容器是否在运行
if [ "$(docker ps -q -f name=wechat)" ]; then
    # 如果容器正在运行,重新启动容器
    echo "wechat 容器正在运行,重新启动容器..."
    docker restart wechat
else
    # 如果容器没有运行,启动容器
    echo "wechat 容器未运行,启动容器..."
    docker run -it --rm -d --name wechat \
        --device /dev/snd \
        --ipc=host \
        -v /tmp/.X11-unix:/tmp/.X11-unix \
        -v $HOME/WeChatFiles:/WeChatFiles \
        -e DISPLAY=unix$DISPLAY \
        -e XMODIFIERS=@im=fcitx \
        -e QT_IM_MODULE=fcitx \
        -e GTK_IM_MODULE=fcitx \
        -e AUDIO_GID=$AUDIO_GID \
        -e USER_GID=$USER_GID \
        -e USER_UID=$USER_UID \
        bestwu/wechat
fi

EOF

2.创建容器微信桌面快捷方式

(1)进入容器内查找微信图标并宿主机上将容器内图标拷贝出来

docker exec -it wechat /bin/bash
find / -type f \( -name "*wechat*.png" -o -name "*wechat*.ico" -o -name "*wechat*.svg" \) 2>/dev/null
docker cp wechat:/usr/share/icons/hicolor/16x16/apps/deepin.com.wechat.svg  /home/zycheng/wechat.svg

(2)创建桌面快捷方式

cat <<EOF >~/.local/share/applications/wechat.desktop
[Desktop Entry]
Name=wechat
Exec=/home/zycheng/桌面/temporary/wechat.sh
Terminal=false
Type=Application
Icon=/home/zycheng/wechat.svg
StartupWMClass=Wechat
Comment=Wechat
MimeType=x-scheme-handler/Wechat;
Categories=Development;

EOF
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值