0

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/* \
...
yes
  • 1
  • 3
  • Besides all other questions that might arise: why Ubuntu 16.04 ? – Marged Aug 16 '20 at 20:10
  • Good question ...:). Because it works. We try to move to 18.04 but have a few issues which we plan to solve. The other question is why not Alpine but this require more work on converting the dockerfile. Nevertheless, ubuntu is just 100 MB while wine + winetricks are almost 3GB – yes Aug 17 '20 at 07:58
  • I search stackoverflow and other online resources but didn't found other solution for running win base application as docker on Linux platform. So I am open for any suggestion which shall help us to reduce docker image size – yes Aug 17 '20 at 10:52

1 Answers1

0

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

user2915097
  • 30,758
  • 6
  • 57
  • 59