Running Visual Basic 6.0 applications on Linux with Wine and Docker
Running legacy Visual Basic 6.0 applications on modern Linux systems can be challenging, especially when you want to avoid modifying your main system configuration. Using Wine in Docker provides an isolated, reproducible environment that’s perfect for this use case.
After researching existing Docker images for this purpose, I couldn’t find any that were actively maintained and up to date with recent Wine versions.
Therefore, I decided to create my own solution. This implementation was inspired by the excellent work in this repository: https://github.com/telyn/docker-vb6/tree/master
Preparing the image
The Dockerfile performs the following steps:
- Installs Wine 11 directly from the official WineHQ repository
- Uses winetricks to install the necessary runtime components for Visual Basic 6.0 applications
- Configures Xvfb (X Virtual Framebuffer) to create a virtual display for running graphical applications headlessly
If you need additional Windows components or libraries, you can easily extend the install.sh script with more winetricks (or also other) commands.
FROM debian:trixie
USER root
# Install X server and tools needed to run winetricks
RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y --no-install-recommends \
xvfb \
xauth \
x11-utils \
x11-xserver-utils \
curl \
unzip \
ca-certificates \
cabextract \
wget \
gpg && \
rm -rf /var/lib/apt/lists/*
# Install wine
RUN wget --progress=dot:giga -O- https://dl.winehq.org/wine-builds/winehq.key | gpg --dearmor | tee /usr/share/keyrings/winehq.gpg
RUN echo "deb [signed-by=/usr/share/keyrings/winehq.gpg] https://dl.winehq.org/wine-builds/debian/ trixie main" > /etc/apt/sources.list.d/winehq-repo.list
RUN apt-get update && \
apt-get install winehq-stable=11.0.0.0~trixie-1 -y --no-install-recommends && \
rm -rf /var/lib/apt/lists/* && \
wine --version
RUN curl -SL 'https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks' -o /usr/local/bin/winetricks \
&& chmod +x /usr/local/bin/winetricks && \
adduser \
--home /home/wine \
--disabled-password \
--shell /bin/bash \
--gecos "user for running a wine application" \
--quiet \
wine
USER wine
ENV HOME=/home/wine
ENV WINEPREFIX=/home/wine/.wine
ENV WINEARCH=win32
WORKDIR /home/wine
COPY install.sh .
RUN bash install.sh
The install.sh script handles the Wine initialization and component installation:
#!/bin/bash
set -x
wineboot --init
wineboot -u
Xvfb :0 -auth ~/.Xauthority -screen 0 1024x768x24 >>~/xvfb.log 2>&1 &
XVFB_PID=$!
export DISPLAY=:0
sleep 2
winetricks -q vb6run comctl32ocx comdlg32ocx richtx32 mdac28
winetricks -q vcrun6
winetricks -q mfc40
# ending with message "Loading of typelib L"C:\\Program files\\Common files\\Microsoft shared\\dao\\dao2535.tlb" failed with error 2". Seems "fine"
winetricks -q jet40
# give some delay to complete pending processes
sleep 30
# -k is needed, otherwise the process hangs forever (propably because some dialog is displayed), -f was not enough
# -k = kill running processes without any cleanup
# -f = force exit for processes that do not exit cleanly
wineboot -u -k
# leads to an error message "X connection to :0 broken (explicit kill or server shutdown)". This is also fine
kill $XVFB_PID
Once you have saved these two files in a directory, you can build the image with:
docker build -t wine11 .
Using the image
As a first test, you can verify the image works by running Notepad (which comes pre-installed with Wine):
xhost +
docker run --rm -ti --net=host --ipc=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --env="QT_X11_NO_MITSHM=1" wine11 wine notepad.exe
Once you’ve confirmed the basic setup works, you can run your own Visual Basic 6.0 applications by mounting the directory containing your executable and launching it with Wine:
xhost +
docker run --rm -ti --net=host --ipc=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --env="QT_X11_NO_MITSHM=1" -v "$PWD":/home/wine/.wine/drive_c/prog wine11 wine "/home/wine/.wine/drive_c/prog/prog.exe"