├── LICENSE ├── entrypoint.sh ├── download_gecko_and_mono.sh ├── README.md └── Dockerfile /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 p0ise 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 如果 DISPLAY 已经存在,则假定使用宿主机的 X11 显示 4 | if [[ -n "$DISPLAY" ]]; then 5 | echo "Using host X11 display at $DISPLAY" 6 | xauth nlist "$DISPLAY" | sed -e 's/^..../ffff/' | xauth -f /root/.Xauthority nmerge - 7 | else 8 | # 启动 xdummy 虚拟显示器的配置文件 9 | cat < /etc/X11/xorg.conf 10 | Section "Device" 11 | Identifier "DummyDevice" 12 | Driver "dummy" 13 | VideoRam 256000 14 | EndSection 15 | 16 | Section "Monitor" 17 | Identifier "DummyMonitor" 18 | HorizSync 28-80 19 | VertRefresh 48-75 20 | EndSection 21 | 22 | Section "Screen" 23 | Identifier "DummyScreen" 24 | Device "DummyDevice" 25 | Monitor "DummyMonitor" 26 | DefaultDepth 24 27 | SubSection "Display" 28 | Depth 24 29 | Modes "1024x768" 30 | EndSubSection 31 | EndSection 32 | 33 | Section "ServerLayout" 34 | Identifier "DummyLayout" 35 | Screen "DummyScreen" 36 | EndSection 37 | EOF 38 | 39 | # 启动 xdummy 虚拟显示器 40 | Xorg -noreset +extension GLX +extension RANDR +extension RENDER -logfile /var/log/xorg.log -config /etc/X11/xorg.conf :0 & 41 | export DISPLAY=:0 42 | fi 43 | 44 | # 执行传入的命令 45 | exec wine "$@" 46 | -------------------------------------------------------------------------------- /download_gecko_and_mono.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Scrapes the Wine source code for versions of mono and gecko to download for a given version of Wine 4 | 5 | get_hrefs () { 6 | local url="$1" 7 | local regexp="$2" 8 | 9 | wget -q -O- "${url}" | sed -E "s/>\n.*|\1|p" | uniq 10 | } 11 | 12 | get_app_ver () { 13 | local app="${1^^}" # Convert to uppercase 14 | local url="https://raw.githubusercontent.com/wine-mirror/wine/wine-${WINE_VER}/dlls/appwiz.cpl/addons.c" 15 | 16 | wget -q -O- "${url}" | grep -E "^#define ${app}_VERSION\s" | awk -F\" '{print $2}' 17 | } 18 | 19 | WINE_VER="$1" 20 | 21 | if [ -z "${WINE_VER}" ]; then 22 | echo "Please specify the version of wine that requires gecko and mono installers" 23 | echo "e.g." 24 | echo " $0 5.0.1" 25 | exit 1 26 | fi 27 | 28 | for APP in "gecko" "mono"; do 29 | # Get the app version required from wine source code 30 | APP_VER=$(get_app_ver "${APP}") 31 | 32 | # Get the list of files to download 33 | APP_URL="http://dl.winehq.org/wine/wine-${APP}/${APP_VER}/" 34 | mapfile -t FILES < <(get_hrefs "${APP_URL}" ".*\.msi") 35 | 36 | # Download the files 37 | [ ! -d "/usr/share/wine/${APP}" ] && mkdir -p "/usr/share/wine/${APP}" 38 | for FILE in "${FILES[@]}"; do 39 | echo "Downloading '${FILE}'" 40 | wget -nv -O "/usr/share/wine/${APP}/${FILE}" "${APP_URL}${FILE}" 41 | done 42 | done 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Wine xdummy Docker 2 | 3 | This repository contains a Docker image for running Windows applications via Wine in a virtual or forwarded X11 display, using `xdummy` for lightweight virtual display support. 4 | 5 | ## Features 6 | 7 | - **Wine Installation**: Installs Wine with configurable version (stable, devel). 8 | - **xdummy Support**: Uses `xdummy` for virtual display in a resource-efficient way. 9 | - **Optional X11 Forwarding**: Supports displaying GUI on host if available. 10 | 11 | ## Getting Started 12 | 13 | ### Build the Image 14 | 15 | ```bash 16 | docker build --build-arg BASE_IMAGE_TAG=20.04 --build-arg WINE_BRANCH=stable -t wine-xdummy:stable-20.04 . 17 | ``` 18 | 19 | ### Run the Image 20 | 21 | To run the image with host display forwarding: 22 | 23 | 1. Enable local access to X11: 24 | 25 | ```bash 26 | xhost +local:root 27 | ``` 28 | 29 | 2. Run the container, specifying the path to the application: 30 | 31 | ```bash 32 | docker run --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix wine-xdummy:stable-20.04 winecfg 33 | ``` 34 | 35 | 3. Revoke the access after use: 36 | 37 | ```bash 38 | xhost -local:root 39 | ``` 40 | 41 | To run without display forwarding, the image will use a virtual display: 42 | 43 | ```bash 44 | docker run --rm wine-xdummy:stable-20.04 /path/to/windows-app.exe 45 | ``` 46 | 47 | ### Additional Configurations 48 | 49 | - **BASE_IMAGE_TAG**: Specifies the base Ubuntu version. 50 | - **WINE_BRANCH**: Specifies the Wine branch (`stable`, `devel`, or `staging`). 51 | - **DISPLAY**: Set automatically for X11 forwarding. 52 | 53 | ## License 54 | 55 | This project is licensed under the MIT License. 56 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # 定义基础镜像和 Wine 分支的构建参数 2 | ARG BASE_IMAGE_TAG="20.04" 3 | FROM ubuntu:${BASE_IMAGE_TAG} 4 | 5 | # 环境变量设置,避免交互并设置默认语言环境 6 | ENV DEBIAN_FRONTEND=noninteractive 7 | ENV LANG=en_US.UTF-8 8 | 9 | # 安装必要的工具和设置 10 | RUN apt-get update && \ 11 | apt-get install -y software-properties-common wget apt-transport-https gnupg2 locales x11-xserver-utils xauth x11-apps xserver-xorg-video-dummy && \ 12 | locale-gen en_US.UTF-8 13 | 14 | # 配置 WineHQ 的仓库和安装 Wine,支持参数化选择 Wine 版本 15 | ARG WINE_BRANCH="stable" 16 | # 配置 i386 架构(对于 64 位系统) 17 | RUN dpkg --add-architecture i386 18 | 19 | # 获取系统的 Codename 并设置 WineHQ 源 20 | RUN . /etc/os-release && CODENAME=${UBUNTU_CODENAME:-${VERSION_CODENAME}} && \ 21 | mkdir -pm755 /etc/apt/keyrings && \ 22 | wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key && \ 23 | wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/${CODENAME}/winehq-${CODENAME}.sources 24 | 25 | # 更新包信息并安装 Wine 26 | RUN apt-get update && \ 27 | apt-get install -y --install-recommends winehq-${WINE_BRANCH} && \ 28 | apt-get clean && rm -rf /var/lib/apt/lists/* 29 | 30 | # 安装 winetricks 31 | RUN wget -nv -O /usr/bin/winetricks https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks && \ 32 | chmod +x /usr/bin/winetricks 33 | 34 | # 复制并执行下载 gecko 和 mono 的脚本 35 | COPY download_gecko_and_mono.sh /root/download_gecko_and_mono.sh 36 | RUN chmod +x /root/download_gecko_and_mono.sh && \ 37 | /root/download_gecko_and_mono.sh "$(wine --version | sed -E 's/^wine-//')" 38 | 39 | # 复制入口脚本到容器中 40 | COPY entrypoint.sh /usr/local/bin/entrypoint.sh 41 | RUN chmod +x /usr/local/bin/entrypoint.sh 42 | 43 | # 设置默认的工作目录 44 | WORKDIR /root 45 | 46 | # 使用独立的入口脚本 47 | ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] 48 | --------------------------------------------------------------------------------