简体   繁体   English

Wine 未在 Google Cloud Run 上运行(Google Cloud Run 的限制)

[英]Wine not running on Google Cloud Run (limitations of google cloud run)

This is my docker file, which is installing wine in order to run some exes that I want to, on Google cloud run:这是我的 docker 文件,它正在安装 wine 以便在 Google 云上运行一些我想要的 exe:

ARG BASE_IMAGE="ubuntu"
ARG TAG="latest"
FROM ${BASE_IMAGE}:${TAG}

# Install prerequisites
RUN apt-get update \
    && DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
        apt-transport-https \
        ca-certificates \
        cabextract \
        git \
        gosu \
        gpg-agent \
        p7zip \
        pulseaudio-utils \
        software-properties-common \
        tzdata \
        unzip \
        wget \
        winbind \
        xvfb \
        zenity \
    && rm -rf /var/lib/apt/lists/*

# Install wine
ARG WINE_BRANCH="stable"
RUN wget -O- -nv https://dl.winehq.org/wine-builds/winehq.key | apt-key add - \
    && apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu/ $(grep VERSION_CODENAME= /etc/os-release | cut -d= -f2) main" \
    && dpkg --add-architecture i386 \
    && apt-get update \
    && DEBIAN_FRONTEND="noninteractive" apt-get install -y --install-recommends winehq-${WINE_BRANCH} \
    && rm -rf /var/lib/apt/lists/*

# Install winetricks
RUN wget -nv https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks -O /usr/bin/winetricks \
    && chmod +x /usr/bin/winetricks

# Download gecko and mono installers
COPY download_gecko_and_mono.sh /root/download_gecko_and_mono.sh
RUN chmod +x /root/download_gecko_and_mono.sh \
    && /root/download_gecko_and_mono.sh "$(dpkg -s wine-${WINE_BRANCH} | grep "^Version:\s" | awk '{print $2}' | sed -E 's/~.*$//')"

RUN apt-get update
RUN apt-get install -y python3.6 python3-pip
RUN pip3 install flask gunicorn
RUN apt-get install -y nginx
COPY . /app

WORKDIR /app
RUN chmod a+x /usr/bin/wine
ENTRYPOINT ["/usr/local/bin/gunicorn","-w","1","--timeout","900","-b","0.0.0.0:8005","app:app"]
EXPOSE 8005

I have tested this container locally on my linux 64 bit machine, and it is able to run the wine commands (app.py is a flask server that calls exes).我已经在我的 linux 64 位机器上本地测试了这个容器,它能够运行 wine 命令(app.py 是一个调用 exes 的 flask 服务器)。 But when I try to call "wine" on the GCR container (I even tried calling it at the beginning of my app.py, which is guaranteed to run), I get this error:但是当我尝试在 GCR 容器上调用“wine”时(我什至尝试在我的 app.py 开头调用它,保证运行),我得到这个错误:

Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process() File "/usr/local/lib/python3.8/dist-packages/gunicorn/workers/base.py", line 119, in init_process self.load_wsgi() File "/usr/local/lib/python3.8/dist-packages/gunicorn/workers/base.py", line 144, in load_wsgi self.wsgi = self.app.wsgi() File "/usr/local/lib/python3.8/dist-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/usr/local/lib/python3.8/dist-packages/gunicorn/app/wsgiapp.py", line 49, in load return self.load_wsgiapp() File "/usr/local/lib/python3.8/dist-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp return util.import_app(self.app_uri) File "/usr/local/lib/python3.8/dist-packages/gunicorn/util.py", line 358, in import_app mod = importlib.import_module(module) File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 783, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/app/app.py", line 27, in <module> print(subprocess.call(["wine"]) File "/usr/lib/python3.8/subprocess.py", line 340, in call with Popen(*popenargs, **kwargs) as p: File "/usr/lib/python3.8/subprocess.py", line 854, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) OSError: [Errno 8] Exec format error: 'wine'

The important line in the error being:错误中的重要行是:

OSError: [Errno 8] Exec format error: 

It is particularly odd because I would assume docker would guarantee portability across linux platforms.这特别奇怪,因为我认为 docker 将保证跨 linux 平台的可移植性。

EDIT:编辑:

The original issue was that I was not using wine64 (gcr only supports linux 64 bit binaries ), which resolved the original issue of wine running.原来的问题是我没有使用wine64(gcr只支持linux 64位二进制文件),解决了原来的wine运行问题。

However, due to Cloud Run fully managed using gVisor sandbox, it was still not possible to get my exe running.但是,由于 Cloud Run 使用 gVisor 沙盒进行完全托管,我的 exe 仍然无法运行。 I have eventually moved to other approaches to solve my problem.我最终转向了其他方法来解决我的问题。

It is very likely that Wine does not work on Cloud Run fully managed. Wine 很可能无法在完全托管的 Cloud Run 上运行。

Cloud Run fully managed uses gVisor sandbox ( https://gvisor.dev/ ), which is an user-space syscall emulator written in Go. Cloud Run 完全托管使用 gVisor 沙盒 ( https://gvisor.dev/ ),这是一个用 Go 编写的用户空间系统调用模拟器。 This environment does not run a real Linux kernel or real Docker runtime.此环境不运行真正的 Linux kernel 或真正的 Docker 运行时。

It's expected that there could be compatibility issues with exotic executables such as Wine (that exercise the syscall APIs to their full extent and corner cases).预计可能存在与诸如 Wine 之类的外来可执行文件的兼容性问题(充分利用系统调用 API 和极端情况)。 However, most server-side apps should be working fine.但是,大多数服务器端应用程序应该可以正常工作。

You can use strace on Cloud Run to identify the culprit syscall and make a feature request to gVisor mentioning you need this on Cloud Run.您可以在 Cloud Run 上使用 strace来识别罪魁祸首系统调用并向 gVisor 提出功能请求,说明您在 Cloud Run 上需要此功能。 Alternatively, you can use Cloud Run for Anthos, which runs on Kubernetes, with a real Linux kernel and Docker (or containerd). Alternatively, you can use Cloud Run for Anthos, which runs on Kubernetes, with a real Linux kernel and Docker (or containerd).

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM