I'm building a docker image which uses Ubuntu as base and has Python 3.11 installed under Wine.
This is my Dockerfile:
FROM ubuntu:jammy
ENV DISPLAY=":0.0"
ENV WINEARCH="win64"
ENV WINEDEBUG="-all"
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ="Europe/Berlin"
WORKDIR /wdir
RUN dpkg --add-architecture i386
RUN mkdir -pm755 /etc/apt/keyrings
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive TZ=Europe/Berlin apt-get install -y wget xvfb git pandoc unoconv
RUN wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
RUN wget -NP /etc/apt/sources.list.d/ \
https://dl.winehq.org/wine-builds/ubuntu/dists/kinetic/winehq-kinetic.sources
RUN apt-get update
RUN apt-get install -y --install-recommends winehq-devel winetricks
RUN wget -O python-installer.exe https://www.python.org/ftp/python/3.11.1/python-3.11.1-amd64.exe
RUN winetricks win10
# Setup dummy screen
RUN Xvfb :0 -screen 0 1024x768x16 & sleep 5s; wine cmd /c python-installer.exe /quiet InstallAllUsers=1 PrependPath=1
RUN wine cmd /c python -m pip install --upgrade pip
CMD ["/bin/bash"]
For some reason, this works only if I'm running on a machine with graphical environment.
When I have no graphical environment (like after running systemctl isolate multi-user.target on my notebook), Python is not found on the system and the call to pip fails.
But when I start the image with docker run -it $IMGHASH and manually run Xvfb :0 -screen 0 1024x768x16 & sleep 5s; wine cmd /c python-installer.exe /quiet InstallAllUsers=1 PrependPath=1 it works an I can successfully launch Python.
Why is this happening? Shouldn't the docker environment be independent from the host environment?