WeChat on Linux

Introduction

Tencent had not been releasing Linux WeChat for many years and Linux users would have to use Web WeChat. In 2021, Tencent separated from WeChat from Weixin, and somehow the WeChat users started not to be able to use Web WeChat anymore. There were other non-official WeChat applications for Linux, however, most of them have been deprecated or not trustworthy.

Running WeChat using Docker container is a good approach, as Docker does not contaminate the native host system environment. Most of the existing Docker WeChat use Wine to emulate Windows WeChat. The configuration is complex and the it has complex dependencies. So examining whether the third-party Docker WeChat is trustworthy is difficult.

In 2022, Tencent surprisingly released the official WeChat Linux build. But the release was for Ubuntu Kylin only. In principle, we should be able to install this WeChat build on Ubuntu as well.

In this blog post, I would like to discuss how to install the latest official WeChat Linux build in Ubuntu Docker image and how to run Docker WeChat.

Docker WeChat

Dockerfile

The following Dockerfile will install WeChat, Chinese language support, and fonts. The configurations and dependencies are simple and the applications being built should be trustworthy.

wechat.Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
locales \
locales-all \
gnupg \
locales \
locales-all \
fcitx-libs-dev \
fcitx-bin \
fcitx-googlepinyin \
fcitx \
fcitx-ui-qimpanel \
fcitx-sunpinyin \
dbus-x11 \
im-config
RUN apt-get clean

# [UbuntuKylin](https://www.ubuntukylin.com/) is a Chinese Ubuntu derivative.
RUN echo "deb http://archive.ubuntukylin.com/ubuntukylin focal-partner main" > /etc/apt/sources.list.d/wechat.list && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 56583E647FFA7DE7

RUN apt-get update && apt-get install -y --no-install-recommends \
weixin \
language-pack-zh* \
chinese* \
fonts-wqy-microhei \
fonts-wqy-zenhei \
xfonts-wqy
RUN apt-get clean

ENV LC_ALL zh_CN.UTF-8
ENV LANG zh_CN.UTF-8
ENV LANGUAGE en_US.UTF-8

ENV GTK_IM_MODULE=fcitx
ENV QT_IM_MODULE=fcitx
ENV XMODIFIERS=@im=fcitx
ENV DefaultIMModule=fcitx

CMD ["weixin", "--no-sandbox"]

Build Docker Image

1
$ docker build -f wechat.Dockerfile --tag=wechat:0.0.1 .

Push Docker Image

1
2
$ docker tag wechat:0.0.1 leimao/wechat:0.0.1
$ docker push leimao/wechat:0.0.1

Pull Docker Image

1
2
$ docker pull leimao/wechat:0.0.1
$ docker tag leimao/wechat:0.0.1 wechat:0.0.1

Run Docker WeChat

We could run Docker WeChat using the following command.

1
2
3
4
5
6
7
8
9
10
11
12
13
$ xhost +
$ docker run \
-it \
--rm \
--ipc=host \
-e DISPLAY=$DISPLAY \
-e XMODIFIERS=@im=fcitx \
-e QT_IM_MODULE=fcitx \
-e GTK_IM_MODULE=fcitx \
-v /tmp/.X11-unix:/tmp/.X11-unix:ro \
-v $HOME/.config/weixin:/root/.config/weixin \
wechat:0.0.1
$ xhost -

Known Issues

Input Methods

Switching input methods does not work for Docker WeChat. However, there is no problem copying and pasting Chinese in Docker WeChat.

Miscellaneous

To install and run WeChat via Wine in a Docker container, please read the blog post “Wine on Docker”. The Chinese input method does work via Wine.

References

Author

Lei Mao

Posted on

01-15-2022

Updated on

08-28-2022

Licensed under


Comments