简体   繁体   中英

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

We developed Windows based application and try to convert it to run as docker in Linux base environment. Unfortunately, one of 3rd party library can't be convert to Linux environment. We built docker image which is ubuntu 16.04 + wine 4.0 + w.netricks which our application can runs on it but all 3 components (ubuntu, wine + w.netrick) weight more than 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? Is there another way to run windows base application as docker container on linux environment?

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/* \
...

We developed Windows based application and try to convert it to run as docker in Linux base environment. Unfortunately, one of 3rd party library can't be convert to Linux environment. We built docker image which is ubuntu 16.04 + wine 4.0 + winetricks which our application can runs on it but all 3 components (ubuntu, wine + winetrick) weight more than 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? Is there another way to run windows base application as docker container on linux environment?

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/* \
...

You install many unneeded packages, you should read carefully

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

which explains why

You should remove xvfb (I guess you need xvfb during the installation and configuration of wine, but not after) and all the "recommended" packages

Look also at

https://github.com/wagoodman/dive

which is an excellent tool if you need to see how efficient is your docker image

Use also

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

it can save some space.

Good hunt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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