openEuler 使用docker-wine运行windows 32位程序

参考我前面的文章,安装基本环境:
openEuler(华为欧拉)安装docker
openEuler(华为欧拉)使用docker安装wine 8+版本,支持32位

示例

我想在wine容器上安装.net7 x86的运行时,使wine容器能够运行.net7开发的32位程序

创建wine容器

使用docker run 命令先创建并运行一个容器

wine的初次设置

32位程序

配置存放32位程序环境的参数:

$ WINEARCH=win32 WINEPREFIX=~/.wine32 winecfg
64位程序

配置存放64位程序环境的参数:

$ WINEARCH=win64 WINEPREFIX=~/.wine4 winecfg

运行程序

32位程序
$ WINEPREFIX=~/.wine32 wine app.exe
64位程序
$ WINEPREFIX=~/.wine64 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.

下载.net7运行时

微软官方下载.net7运行时,本文以dotnet-runtime-7.0.8-win-x86.exe为例。

安装.net7运行时到wine容器

启动wine
#允许任何X客户端连接到X Server。这是必需的,以便Docker容器中的Wine应用程序可以连接到宿主机的X Server。当你需要用wine安装一些环境,比如.net的运行时,需要打开X Server.
xhost +
#使用run命令,会创建一个新的容器并启动。命令中 -v $(pwd):/mnt很重要,意思是将linux下当前目录共享给容器下的的/mnt目录,共享后,在容器的控制台中,使用cd /mnt进入到mnt目录后,可以访问到linux之前那个目录里的资源文件。
docker run -it -e DISPLAY=$DISPLAY -v $(pwd):/mnt -v /tmp/.X11-unix:/tmp/.X11-unix:ro -p 3000:3000 tianon/wine:8.0.1
安装.net7

记住,我将dotnet-runtime-7.0.8-win-x86.exe文件,放在执行docker run 这条命令时的目录里的。

#进入共享目录,访问安装包
cd /mnt
wine dotnet-runtime-7.0.8-win-x86.exe
#根据弹出的窗口安装即可

另外,该容器也支持wine64指令哈,可运行64位的程序

运行windwos程序

将需要运行的windows程序放在容器映射的共享路径中,然后使用wine xxxxx.exe运行程序即可。

posted @ 2023-07-17 15:16  木人草  阅读(797)  评论(0编辑  收藏  举报