【问题标题】:running windows base application embedded in ubuntu or alpine based docker image运行嵌入在 ubuntu 或基于 alpine 的 docker 映像中的 windows 基础应用程序
【发布时间】:2020-08-16 19:59:33
【问题描述】:

我们开发了基于 Windows 的应用程序,并尝试将其转换为在 Linux 基础环境中作为 docker 运行。 不幸的是,第 3 方库之一无法转换为 Linux 环境。 我们构建了 docker 镜像,它是 ubuntu 16.04 + wine 4.0 + winetricks,我们的应用程序可以在其上运行,但所有 3 个组件(ubuntu、wine + winetrick)的重量都超过 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/* \
...

【问题讨论】:

  • 除了可能出现的所有其他问题:为什么是 Ubuntu 16.04?
  • 好问题...:)。因为它有效。我们尝试迁移到 18.04,但有一些我们计划解决的问题。另一个问题是为什么不是 Alpine,但这需要更多的工作来转换 dockerfile。尽管如此,ubuntu 只有 100 MB,而 wine + winetricks 几乎是 3GB
  • 我搜索了 stackoverflow 和其他在线资源,但没有找到在 Linux 平台上将 win 基础应用程序作为 docker 运行的其他解决方案。所以我愿意接受任何有助于我们减少 docker 图像大小的建议

标签: docker dockerfile ubuntu-16.04 alpine wine


【解决方案1】:

你安装了很多不需要的包,你应该仔细阅读

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

这样可以节省一些空间。

很好的狩猎

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-11
    • 1970-01-01
    • 1970-01-01
    • 2020-08-30
    • 1970-01-01
    • 2018-09-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多