Wine In Docker
Introduction
Wine is a common tool to run Windows applications on Linux. In this blog post, I would like to discuss how to run Windows applications, such as WeChat, via Wine in a Linux Docker container.
Docker Wine
We will quickly go through the Wine Dockerfile and the basic Wine usages. All the commands could also be translated to a native Ubuntu operating system.
Dockerfile
The following Dockerfile has the Wine, languages, Chinese fonts, and display scaling installed.
1 | FROM ubuntu:20.04 |
Build Docker Image
To build the Docker image, please run the following command.
1 | $ docker build -f wine.Dockerfile --tag wine:20.04 . |
Run Docker Container
To run the Docker container, please run the following command with additional Docker arguments if necessary.
1 | $ xhost + |
Configure Wine
For Win32 applications, we create a directory ~/.wine32
to store the configurations.
1 | $ WINEARCH=win32 WINEPREFIX=~/.wine32 winecfg |
For Win64 applications, we create a directory ~/.wine64
to store the configurations.
1 | $ WINEARCH=win64 WINEPREFIX=~/.wine64 winecfg |
Run Application
For Win32 applications, we specify the Win32 configuration directory as WINEPREFIX
before wine
.
1 | $ WINEPREFIX=~/.wine32 wine app.exe |
For Win64 applications, we specify the Win64 configuration directory as WINEPREFIX
before wine
.
1 | $ WINEPREFIX=~/.wine64 wine app.exe |
Run Display Scaling
For some old applications, the display usually is very small. We could scale the display using a scaling script.
For example, to scale the display of app.exe by 1.5x, we could run the following command.
1 | $ WINEPREFIX=~/.wine32 run_scaled --scale=1.5 wine app.exe |
Save Docker Image
We can save the Docker image from the Docker container we just set up using docker commit
. In case we accidentally turn off the Docker container, we can always start the Docker container again from the Docker image without having to reinstall Wine and the application.
Example
We will use running Windows WeChat as an example.
Download WeChat
1 | $ wget https://dldir1.qq.com/weixin/Windows/WeChatSetup.exe |
Run Docker Container
1 | $ xhost + |
Notice --rm
has been removed and -e XMODIFIERS=@im=fcitx
, -e QT_IM_MODULE=fcitx
, -e GTK_IM_MODULE=fcitx
has been added to enable the fcitx
input from the host computer.
Configure Wine
1 | $ WINEARCH=win64 WINEPREFIX=~/.wine64 winecfg |
Make sure virtual desktop is used in winecfg
. In my case, I used resolution 2560 x 1440
for the virtual desktop.
Install WeChat
1 | $ cd /mnt |
WeChat will be installed in ~/.wine64/drive_c/Program\ Files\ \(x86\)/Tencent/WeChat/WeChat.exe
by default.
Run WeChat
1 | $ WINEPREFIX=~/.wine64 wine ~/.wine64/drive_c/Program\ Files\ \(x86\)/Tencent/WeChat/WeChat.exe |
I tried fcitx
input from the host computer to the WeChat in the container and it worked fine.
References
Wine In Docker