Skip to content

Instantly share code, notes, and snippets.

@arpieb
Created February 16, 2023 20:42
Show Gist options
  • Save arpieb/edb6ea64611baaaaec0a26213e0f1e14 to your computer and use it in GitHub Desktop.
Save arpieb/edb6ea64611baaaaec0a26213e0f1e14 to your computer and use it in GitHub Desktop.
Set up a Wine environment in a Docker container with Python 3.8 installed
################
# Attempt to run Windows scripts in a Docker container (for K8s deployment)
# Inspiration/material from:
# https://betterprogramming.pub/how-to-run-any-windows-cli-app-in-a-linux-docker-container-318cd49bdd25
################
FROM ubuntu:22.04
# Core system packages
RUN apt -y update
RUN apt -y install wget
# Install Wine stack (https://wiki.winehq.org/Main_Page)
# NOTE these repos are platform-version specific
ENV WINEDEBUG=fixme-all
RUN dpkg --add-architecture i386 && \
mkdir -pm755 /etc/apt/keyrings && \
wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key && \
wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources && \
apt update && \
apt -y install --install-recommends winehq-stable winbind cabextract
# Install "dummy" X Server
RUN apt install -y xvfb
ENV DEBIAN_FRONTEND=noninteractive
ENV DISPLAY :1
# Install Mono framework
RUN wget -P /mono https://dl.winehq.org/wine/wine-mono/7.4.0/wine-mono-7.4.0-x86.msi && \
wineboot -u && msiexec /i /mono/wine-mono-7.4.0-x86.msi && \
rm -rf /mono/wine-mono-7.4.0-x86.msi
# Install Python
RUN wget https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe && \
xvfb-run wine64 python-3.8.10-amd64.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0 SimpleInstall=1 /nogui && \
rm -f python-3.8.10-amd64.exe
@arpieb
Copy link
Author

arpieb commented Feb 8, 2024

Glad you got some traction and I was able to help in some way! My use case was a Python-based script that used pywin32 to load and analyze Windows-only executables, and I was experimenting to see if I could get that to run in an existing k8s cluster on RHEL hosts. I had limited success before the spike was abandoned.

Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment