在linux上使用微信和QQ並不算什麼新鮮事,之前採用wine,github,crossover,snap等的方式都安裝過,其中最方便的還是github上的下載,然後雙擊運行,就可以了,但是它貌似已經不維護了,github上的更新時間是2年前,而且我覺得現在使用docker的方式也比那個好一點。
docker客戶端給docker守護進程發送命令,docker守護進程從遠端的倉庫中獲取鏡像,使用鏡像創建一個容器,客戶端就可以使用命令操作這個容器。這個鏡像怎麼來的呢?就是把一個應用除內核外的所有運行環境打包,所以它的移植性非常好。
先展示一下我的安裝結果:
docker分企業版(docker-ee)和社區版(docker-ce) ,我們自己玩就安裝社區版就可以了。
我的系統是:
guoyz@debian:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.9 (stretch)
Release: 9.9
Codename: stretch
1,修改源
guoyz@debian:~$ cat /etc/apt/sources.list
deb http://mirrors.163.com/debian/ stretch main non-free contrib
deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.163.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib
deb [arch=amd64] https://download.docker.com/linux/debian stretch stable
2, 可以使用國內其它源,修改完之後,更新一下:
guoyz@debian:~$ sudo apt-get update
3,安裝一些必備軟件包
guoyz@debian:~$ sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
4,將Docker存儲庫添加到APT源(第一步中包含了)
guoyz@debian:~$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
之後,sudo apt-get update更新一下包列表
5,安裝docker-ce
guoyz@debian:~$ sudo apt-get install docker-ce
6,檢查是否運行,就想linux的其它服務一樣,看到active就是在運行了
guoyz@debian:~$ sudo systemctl status docker
[sudo] guoyz 的密碼:
0000000000000000000000000000000000000000000000000000000000
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: e
Active: active (running) since Sat 2019-07-06 11:02:49 CST; 5h 33min ago
Docs: https://docs.docker.com
Main PID: 738 (dockerd)
Tasks: 15
Memory: 57.9M
CPU: 6.649s
CGroup: /system.slice/docker.service
下面這步可以不做(第7步),就是爲了不用在docker前面加sudo來使用docker,就是爲了方便。默認情況下,該docker
命令只能由root用戶或docker組中的用戶運行,該用戶在Docker的安裝過程中自動創建。
7,將用戶USER添加到docker組中
guoyz@debian:~$ sudo usermod -aG docker ${USER}
8,把鏡像pull到本地
guoyz@debian:~$ docker pull bestwu/qq
這個估計要等幾分鐘了。
9,啓動qq(第一次需要這樣,創建容器)
docker run -d --name qq --device /dev/snd/ -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/TencenFiles:/TencentFiles -e DISPLAY=unix$DISPLAY -e XMODIFIERS=@im=fcitx -e QT_IM_MODULE=fcitx -e GTK_IM_MODULE=fcitx -e AUDIO_GID=`getent group audio | cut -d: -f3` -e VIDEO_GID=`getent group video | cut -d: -f3` -e GID=`id -g` -e UID=`id -u` bestwu/qq:im
之後會出現登陸界面。
10,查看本地有哪些容器
guoyz@debian:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
76ebee5f0fa0 bestwu/wechat "/entrypoint.sh" 18 hours ago Up 6 hours wechat
a110eba9afc7 bestwu/qq:im "/entrypoint.sh" 18 hours ago Up 6 hours
11,可以使用CONTAINER ID來啓動容器
guoyz@debian:~$ docker start a110eba9afc7
12,微信的安裝也是一樣的,如果安裝不成功的,請參考下面兩個鏈接。
docker的功能非常強大,自己去挖掘。