如何让我的Win32应用程序在Docker中与Wine一起运行?

cgyqldqp  于 2023-06-05  发布在  Docker
关注(0)|答案(2)|浏览(302)

我有一个Win32应用程序,它公开了一个REST端点,并显示一个窗口来记录请求。它是用 Delphi 编写的,是32位的。
我已经在Ubuntu(20.04)中使用Wine(4.0.4)运行了它。它直接从盒子里跑出来。我创建一个32位前缀并启动它。一切都很好。这是一个干净的Ubuntu虚拟机,只安装了Wine。
我现在试图将其放置在Docker容器中,但无法运行它。我使用xvfb-run来支持UI。
当我尝试在容器中运行应用程序时,我收到以下消息/警告/错误:

0010:err:ole:marshal_object couldn't get IPSFactory buffer for interface {00000131-0000-0000-c000-000000000046}
0010:err:ole:marshal_object couldn't get IPSFactory buffer for interface {6d5140c1-7436-11ce-8034-00aa006009fa}
0010:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hres=0x80004002
0010:err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, 80004002
0010:err:ole:get_local_server_stream Failed: 80004002

但是,APP似乎启动了。当我向端口9000(应用程序监听的端口)发出请求时,我看到更多的错误报告(并且没有得到响应---我得到套接字关闭)。这些错误是:

0019:err:ole:CoGetClassObject class {88d96a05-f192-11d4-a65f-0040963251e5} not registered
0019:err:ole:create_server class {88d96a05-f192-11d4-a65f-0040963251e5} not registered
0019:err:ole:CoGetClassObject no class object {88d96a05-f192-11d4-a65f-0040963251e5} could be created for context 0x5

我不确定我的容器中缺少了什么,因为它在桌面环境中运行得很好。
我的Dockerfile如下:

FROM ubuntu:20.04

RUN apt-get update

RUN apt-get install -y wget software-properties-common gnupg2 xvfb

RUN dpkg --add-architecture i386
RUN wget -nc https://dl.winehq.org/wine-builds/winehq.key
RUN apt-key add winehq.key
RUN add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ focal main'
RUN apt-get update
RUN apt-get install -y winehq-stable winetricks winbind

RUN apt-get clean -y
RUN apt-get autoremove -y

ENV WINEDEBUG=fixme-all

ENV WINEPREFIX=/root/.catalyst
ENV WINEARCH=win32
RUN xvfb-run winecfg

RUN winetricks msxml6

WORKDIR /root

COPY app catalyst

EXPOSE 9000

CMD ["xvfb-run", "wine", "/root/catalyst/CATALYSTWeb.exe"]
8ehkhllq

8ehkhllq1#

我解决了下面的Dockerfile。
我还必须在启动我的应用程序之前添加一个sleep 1s,以允许一些服务启动。

FROM ubuntu:20.04

RUN apt-get update

RUN apt-get install -y wget software-properties-common gnupg2 winbind xvfb

RUN dpkg --add-architecture i386
RUN wget -nc https://dl.winehq.org/wine-builds/winehq.key
RUN apt-key add winehq.key
RUN add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ focal main'
RUN apt-get update
RUN apt-get install -y winehq-stable

RUN apt-get install -y winetricks

RUN apt-get clean -y
RUN apt-get autoremove -y

ENV WINEDEBUG=fixme-all

RUN winetricks msxml6

COPY app /root/catalyst
COPY startup.sh /root/startup.sh
RUN chmod gou+x /root/startup.sh

EXPOSE 9000

CMD ["/root/startup.sh"]

startup.sh

#!/usr/bin/env bash

sleep 1s
xvfb-run wine /root/catalyst/CATALYSTMWeb.exe
gopyfrb3

gopyfrb32#

下面是一个更好的DockerFile版本:

FROM ubuntu:20.04

# Specify a workdir, to better organize your files inside the container. 
WORKDIR /yourapp

# Update package lists and install required packages
RUN apt-get update && \
    apt-get install -y wget software-properties-common gnupg2 winbind xvfb

# Add Wine repository and install Wine
RUN dpkg --add-architecture i386 && \
    wget -nc https://dl.winehq.org/wine-builds/winehq.key && \
    apt-key add winehq.key && \
    add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ focal main' && \
    apt-get update && \
    apt-get install -y winehq-stable

# Install additional packages and configure Wine
RUN apt-get install -y winetricks && \
    winetricks msxml6

# Cleanup unnecessary files
RUN apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENV WINEDEBUG=fixme-all

COPY app /root/catalyst
COPY startup.sh /root/startup.sh
RUN chmod gou+x /root/startup.sh

EXPOSE 9000

CMD ["/root/startup.sh"]

相关问题