簡體   English   中英

運行嵌入在 ubuntu 中的 windows 基礎應用程序或基於 alpine 的 docker 圖像

[英]running windows base application embedded in ubuntu or alpine based docker image

我們開發了基於 Windows 的應用程序,並嘗試將其轉換為在 Linux 基礎環境中以 docker 運行。 不幸的是,第 3 方庫之一無法轉換為 Linux 環境。 我們構建了 docker 圖像,即 ubuntu 16.04 + wine 4.0 + w.netricks,我們的應用程序可以在其上運行,但所有 3 個組件(ubuntu、wine + w.netrick)的重量都超過 3GB。 下面是我們用來構建 docker 圖像的 Dockerfile 的一部分我們的應用程序是 64 位的,結合了 python 和 C++ 代碼我們如何減少 docker 的大小? 還有另一種方法可以在 linux 環境中將 windows 基礎應用程序作為 docker 容器運行嗎?

FROM ubuntu:16.04
# reccomended to add 32bit arch for wine
RUN dpkg --add-architecture i386 \
# install things to help install wine
 && apt-get update \
 && apt-get install -y  --allow-unauthenticated wget software-properties-common software-properties-common debconf-utils python-software-properties apt-transport-https cabextract telnet xvfb unzip build-essential \
# register repo and install winehq
 && wget -nc https://dl.winehq.org/wine-builds/Release.key \
 && apt-key add Release.key \
 && wget -nc https://dl.winehq.org/wine-builds/winehq.key \
 && apt-key add winehq.key \
 && apt-add-repository https://dl.winehq.org/wine-builds/ubuntu/ \
 && apt-get update \
 && apt-get install -y xvfb \
 && apt-get install --install-recommends -y  --allow-unauthenticated winehq-stable

# setup vars for wine
ENV DISPLAY=":0.0"
ENV WINEARCH="win64"
ENV WINEPREFIX="/root/.wine64"
ENV WINESYSTEM32="/root/.wine64/drive_c/windows/system32"
ENV WINEDLLOVERRIDES="mscoree,mshtml="
ENV WINEDEBUG=-all


COPY scripts /root/scripts

# pull down winetricks, and install requirements
# vcrun2015 and vcrun2010 are Visual Studio C++ Redistributables
RUN set -e \
 && mkdir -p $WINEPREFIX \
 && cd $WINEPREFIX \
 && wget https://raw.githubusercontent.com/Winetricks/winetricks/20190615/src/winetricks \
 && chmod +x winetricks \
 && xvfb-run wine wineboot --init \
 && xvfb-run wineserver -w \
 && xvfb-run sh ./winetricks -q d3dx9 corefonts vcrun2015 

RUN set -x \
    && pythonVersions='python3.7' \
    && apt-get update \
    && apt-get install -y --allow-unauthenticated --no-install-recommends software-properties-common \
    && apt-add-repository -y ppa:deadsnakes/ppa  \
    && apt-get update \
    && apt-get install -y  --allow-unauthenticated --no-install-recommends $pythonVersions \
    && rm -rf /var/lib/apt/lists/* \
...

我們開發了基於 Windows 的應用程序,並嘗試將其轉換為在 Linux 基礎環境中作為 docker 運行。 不幸的是,第 3 方庫之一無法轉換為 Linux 環境。 我們構建了 docker 映像,即 ubuntu 16.04 + wine 4.0 + winetricks,我們的應用程序可以在其上運行,但所有 3 個組件(ubuntu、wine + winetrick)的重量超過 3GB。 Below is the part of Dockerfile which we use to build the docker image Our application is 64bit and combines python and C++ code How can we reduce docker size? 是否有另一種方法可以在 linux 環境中將 windows 基礎應用程序作為 docker 容器運行?

FROM ubuntu:16.04
# reccomended to add 32bit arch for wine
RUN dpkg --add-architecture i386 \
# install things to help install wine
 && apt-get update \
 && apt-get install -y  --allow-unauthenticated wget software-properties-common software-properties-common debconf-utils python-software-properties apt-transport-https cabextract telnet xvfb unzip build-essential \
# register repo and install winehq
 && wget -nc https://dl.winehq.org/wine-builds/Release.key \
 && apt-key add Release.key \
 && wget -nc https://dl.winehq.org/wine-builds/winehq.key \
 && apt-key add winehq.key \
 && apt-add-repository https://dl.winehq.org/wine-builds/ubuntu/ \
 && apt-get update \
 && apt-get install -y xvfb \
 && apt-get install --install-recommends -y  --allow-unauthenticated winehq-stable

# setup vars for wine
ENV DISPLAY=":0.0"
ENV WINEARCH="win64"
ENV WINEPREFIX="/root/.wine64"
ENV WINESYSTEM32="/root/.wine64/drive_c/windows/system32"
ENV WINEDLLOVERRIDES="mscoree,mshtml="
ENV WINEDEBUG=-all


COPY scripts /root/scripts

# pull down winetricks, and install requirements
# vcrun2015 and vcrun2010 are Visual Studio C++ Redistributables
RUN set -e \
 && mkdir -p $WINEPREFIX \
 && cd $WINEPREFIX \
 && wget https://raw.githubusercontent.com/Winetricks/winetricks/20190615/src/winetricks \
 && chmod +x winetricks \
 && xvfb-run wine wineboot --init \
 && xvfb-run wineserver -w \
 && xvfb-run sh ./winetricks -q d3dx9 corefonts vcrun2015 

RUN set -x \
    && pythonVersions='python3.7' \
    && apt-get update \
    && apt-get install -y --allow-unauthenticated --no-install-recommends software-properties-common \
    && apt-add-repository -y ppa:deadsnakes/ppa  \
    && apt-get update \
    && apt-get install -y  --allow-unauthenticated --no-install-recommends $pythonVersions \
    && rm -rf /var/lib/apt/lists/* \
...

你安裝了很多不需要的包,你應該仔細閱讀

https://www.dajobe.org/blog/2015/04/18/making-debian-docker-images-smaller/

這解釋了為什么

您應該刪除 xvfb(我猜您在安裝和配置 wine 期間需要 xvfb,但之后不需要)和所有“推薦”包

也看看

https://github.com/wagoodman/dive

如果您需要查看 docker 圖像的效率,這是一個很好的工具

也用

https://github.com/jwilder/docker-squash

它可以節省一些空間。

好狩獵

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM