{"id":184,"date":"2025-01-21T14:59:25","date_gmt":"2025-01-21T06:59:25","guid":{"rendered":"https:\/\/qkd-app.koudaipc.com\/?p=184"},"modified":"2026-01-27T21:26:25","modified_gmt":"2026-01-27T13:26:25","slug":"%e4%bd%bf%e7%94%a8-docker-%e8%bf%9b%e8%a1%8c-qemu-w64-%e7%9a%84%e4%ba%a4%e5%8f%89%e7%bc%96%e8%af%91","status":"publish","type":"post","link":"https:\/\/ns1.koudaipc.com\/en\/2025\/01\/21\/%e4%bd%bf%e7%94%a8-docker-%e8%bf%9b%e8%a1%8c-qemu-w64-%e7%9a%84%e4%ba%a4%e5%8f%89%e7%bc%96%e8%af%91\/","title":{"rendered":"\u4f7f\u7528 docker \u8fdb\u884c QEMU W64 \u7684\u4ea4\u53c9\u7f16\u8bd1"},"content":{"rendered":"<p>\u672c\u6587\u8bb0\u5f55\u5728 Debian 12 \u4e0a\u5229\u7528 docker \u8fdb\u884c QEMU W64 \u7684\u4ea4\u53c9\u7f16\u8bd1\u6b65\u9aa4<\/p>\n<h1>\u5b89\u88c5 docker \u7f16\u8bd1\u73af\u5883<\/h1>\n<p>\u9996\u5148\uff0c\u5728Debian 12\u7cfb\u7edf\u4e2d\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u5b89\u88c5Docker\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo apt update\nsudo apt install docker.io<\/code><\/pre>\n<p>\u542f\u52a8Docker\u670d\u52a1\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo systemctl start docker<\/code><\/pre>\n<p>\u5728 docker \u65b0\u76ee\u5f55\u4e2d\u521b\u5efa Dockerfile \u6587\u4ef6<\/p>\n<pre><code class=\"language-bash\"># \u4fbf\u7528Debian 12\u4f5c\u4e3a\u57fa\u7840\u955c\u50cf\nFROM debian:12\n\n# \u8bbe\u7f6e\u5de5\u4f5c\u76ee\u5f55\nWORKDIR \/app\n\n# \u66f4\u65b0apt\u6e90\u4e3a\u56fd\u5185\u955c\u50cf\nRUN sed -i &amp;#039;s\/deb.debian.org\/mirrors.aliyun.com\/g&amp;#039;  \/etc\/apt\/sources.list.d\/debian.sources\n\n#\u3001\u5b89\u88c5\u8f6f\u4ef6\u5305\nRUN apt update<\/code><\/pre>\n<h1>\u914d\u7f6e docker \u8fd0\u884c\u73af\u5883<\/h1>\n<p>\u9996\u5148\u914d\u7f6e docker.io \u7684 registry \u955c\u50cf\uff0c\u65b0\u5efa \/etc\/docker\/daemon.json \u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-bash\">{\n  &amp;quot;registry-mirrors&amp;quot;: [&amp;quot;https:\/\/docker.1panel.dev&amp;quot;]\n}<\/code><\/pre>\n<p>\u4ee5\u4e0a\u8868\u793a docker daemon \u4f7f\u7528 1panel.dev \u7684 docker \u955c\u50cf<\/p>\n<p>\u7136\u540e\u5728 docker \u65b0\u76ee\u5f55\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"language-bash\">docker build .\/<\/code><\/pre>\n<p>docker \u6839\u636e\u76ee\u5f55\u4e2d\u7684 Dockerfile \u6307\u4ee4\u6784\u5efa\u8fd0\u884c\u73af\u5883<\/p>\n<h1>\u51c6\u5907 QEMU W64 \u7f16\u8bd1\u73af\u5883<\/h1>\n<p>\u9996\u5148\u8fd0\u884c docker \u955c\u50cf\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"language-bash\">docker run --name qemu-w64 -it -d -v --rm debian:12 bash<\/code><\/pre>\n<p>\u7136\u540e\uff0c\u63a5\u5165 docker \u5bb9\u5668\u7684\u63a7\u5236\u53f0\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"language-bash\">docker attach qemu-w64<\/code><\/pre>\n<p>\u63a5\u4e0b\u6765\u5b89\u88c5\u4ea4\u53c9\u7f16\u8bd1 QEMU W64 \u6240\u9700\u8981\u7684\u5de5\u5177<\/p>\n<pre><code class=\"language-bash\">apt update\napt install -y vim curl\napt install -y git ninja-build iasl bzip2 meson\napt install -y g++-mingw-w64 mingw-w64 mingw-w64-tools mingw-w64-x86-64-dev nsis mono-devel\napt install -y python3 python3-venv python3-sphinx python3-msmb-theme<\/code><\/pre>\n<p>\u7136\u540e\u4e0b\u8f7d\u5b89\u88c5 msys2 \u7684 mingw64 \u8f6f\u4ef6\u5305<\/p>\n<pre><code class=\"language-bash\">apt install -y pacman-package-manager<\/code><\/pre>\n<pre><code class=\"language-bash\">pacman -Sy<\/code><\/pre>\n<p>1\u3001<\/p>\n<pre><code class=\"language-bash\">pacman -Syu<\/code><\/pre>\n<p>2\u3001<\/p>\n<pre><code class=\"language-bash\">pacman -Su<\/code><\/pre>\n<p>3\u3001\u53ef\u9009\uff0c\u57fa\u672c\u7f16\u8bd1\u5de5\u5177\uff0c\u5728 debian cross compile \u4e2d\u4e0d\u9700\u8981<\/p>\n<pre><code class=\"language-bash\">pacman -Sy --noconfirm base-devel mingw-w64-x86_64-toolchain git python ninja  python-setuptools\npacman -Sy --noconfirm msys2-w32api-runtime\npacman -Sy --noconfirm base-devel mingw-w64-x86_64-toolchain git python ninja<\/code><\/pre>\n<pre><code class=\"language-bash\">cd \/mingw64\/bin\n\ncp x86_64-w64-mingw32-gcc-ar.exe x86_64-w64-mingw32-ar.exe\ncp x86_64-w64-mingw32-gcc-nm.exe x86_64-w64-mingw32-nm.exe\ncp x86_64-w64-mingw32-gcc-ranlib.exe x86_64-w64-mingw32-ranlib.exe\n\ncp widl.exe x86_64-w64-mingw32-widl.exe\ncp windmc.exe x86_64-w64-mingw32-windmc.exe\ncp windres.exe x86_64-w64-mingw32-windres.exe\n<\/code><\/pre>\n<p>4\u3001\u57fa\u672c\u5e93<\/p>\n<pre><code class=\"language-bash\">pacman -Sy --noconfirm mingw-w64-x86_64-glib2\npacman -Sy --noconfirm mingw-w64-x86_64-pixman\npacman -Sy --noconfirm mingw-w64-x86_64-ncurses<\/code><\/pre>\n<p>5\u3001GTK\uff0cSDL\u548cSLiRP\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Sy --noconfirm mingw-w64-x86_64-gtk3\npacman -Sy --noconfirm mingw-w64-x86_64-SDL2\npacman -Sy --noconfirm mingw-w64-x86_64-SDL2_gfx\npacman -Sy --noconfirm mingw-w64-x86_64-SDL2_image\npacman -Sy --noconfirm mingw-w64-x86_64-SDL2_mixer\npacman -Sy --noconfirm mingw-w64-x86_64-SDL2_net\npacman -Sy --noconfirm mingw-w64-x86_64-SDL2_pango\npacman -Sy --noconfirm mingw-w64-x86_64-SDL2_sound\npacman -Sy --noconfirm mingw-w64-x86_64-SDL2_ttf\npacman -Sy --noconfirm mingw-w64-x86_64-libslirp<\/code><\/pre>\n<p>6\u3001SPICE\u548cQXL\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Sy --noconfirm mingw-w64-x86_64-spice-protocol\npacman -Sy --noconfirm mingw-w64-x86_64-spice<\/code><\/pre>\n<p>7\u3001OpenGL\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Sy --noconfirm mingw-w64-x86_64-virglrenderer\npacman -Sy --noconfirm mingw-w64-x86_64-libepoxy<\/code><\/pre>\n<p>8\u3001capstone\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Sy --noconfirm mingw-w64-x86_64-capstone<\/code><\/pre>\n<p>9\u3001libssh\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Sy --noconfirm mingw-w64-x86_64-libssh<\/code><\/pre>\n<p>10\u3001libusb\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Sy --noconfirm mingw-w64-x86_64-libusb\npacman -Sy --noconfirm mingw-w64-x86_64-libusb-win32<\/code><\/pre>\n<p>11\u3001pthread\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Sy --noconfirm mingw-w64-x86_64-libwinpthread-git\npacman -Sy --noconfirm mingw-w64-x86_64-winpthreads-git<\/code><\/pre>\n<p>12\u3001document\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Syu --noconfirm mingw-w64-x86_64-python-sphinx\npacman -Syu --noconfirm mingw-w64-x86_64-python-sphinx_rtd_theme<\/code><\/pre>\n<p>13\u3001JACK\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Syu --noconfirm mingw-w64-x86_64-jack2<\/code><\/pre>\n<p>14\u3001USB net redir\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Syu --noconfirm mingw-w64-x86_64-usbredir<\/code><\/pre>\n<p>15\u3001SASL\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Syu --noconfirm mingw-w64-x86_64-cyrus-sasl<\/code><\/pre>\n<p>16\u3001libcbor\u652f\u6301<\/p>\n<pre><code class=\"language-bash\"> pacman -Syu --noconfirm mingw-w64-x86_64-libcbor<\/code><\/pre>\n<p>17\u3001snappy\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Syu --noconfirm mingw-w64-x86_64-snappy<\/code><\/pre>\n<p>18\u3001libnfs\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Syu --noconfirm mingw-w64-x86_64-libnfs<\/code><\/pre>\n<p>19\u3001nettle\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Syu --noconfirm mingw-w64-x86_64-nettle<\/code><\/pre>\n<p>20\u3001libgcrypt\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Syu --noconfirm mingw-w64-x86_64-libgcrypt<\/code><\/pre>\n<p>21\u3001dtc\u652f\u6301<\/p>\n<pre><code class=\"language-bash\">pacman -Syu --noconfirm mingw-w64-x86_64-dtc<\/code><\/pre>\n<p>8\u3001\u8bbe\u7f6e pkgconfig \u73af\u5883\u53d8\u91cf<\/p>\n<pre><code class=\"language-bash\">export PKG_CONFIG_PATH=&amp;quot;\/mingw64\/share\/pkgconfig\/:\/mingw64\/lib\/pkgconfig\/:$PKG_CONFIG_PATH&amp;quot;\nexport PKG_CONFIG_LIBDIR=&amp;quot;\/mingw64\/lib\/pkgconfig\/:$PKG_CONFIG_LIBDIR&amp;quot;\nexport PKG_CONFIG_SYSROOT_DIR=&amp;quot;&amp;quot;<\/code><\/pre>\n<p>9\u3001\u7f16\u8bd1<\/p>\n<pre><code class=\"language-bash\">.\/configure --cross-prefix=x86_64-w64-mingw32-   --extra-cflags=&amp;quot;-I\/mingw64\/include&amp;quot;  --extra-cxxflags=&amp;quot;-I\/mingw64\/include&amp;quot;  --extra-ldflags=&amp;quot;-L\/mingw64\/lib&amp;quot;  --enable-gtk --enable-sdl --enable-opengl --enable-virglrenderer --enable-slirp --enable-nettle --enable-gnutls --enable-rng-none --enable-debug<\/code><\/pre>\n<pre><code class=\"language-bash\">.\/configure --cross-prefix=x86_64-w64-mingw32-   --extra-cflags=&amp;quot;-I\/mingw64\/include  -D__MINGW32__ -D_FORTIFY_SOURCE=1 -D__OPTIMIZE__=0 -D__clang_major__=0 -D__clang_minor__=0&amp;quot;  --extra-cxxflags=&amp;quot;-I\/mingw64\/include  -D__cplusplus=201103L&amp;quot; --extra-ldflags=&amp;quot;-L\/mingw64\/lib&amp;quot;  --enable-gtk --enable-sdl --enable-opengl --enable-virglrenderer --enable-slirp --enable-nettle --enable-gnutls --enable-rng-none --enable-debug<\/code><\/pre>\n<p>\u7136\u540e\u4e0b\u8f7d cygwin \u7684\u8f6f\u4ef6\u5305\uff0c\u8f6c\u6362\u4e3a deb \u683c\u5f0f\u6587\u4ef6<\/p>\n<pre><code class=\"language-bash\">git clone git@gitee.com:david921518\/cyg2deb.git\ncd cyg2deb\npython3 -m venv env<\/code><\/pre>\n<p>\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b python \u865a\u62df\u73af\u5883\uff1a<\/p>\n<pre><code class=\"language-bash\">source env\/bin\/activate<\/code><\/pre>\n<p>\u5b89\u88c5 zstd \u652f\u6301\u5305<\/p>\n<pre><code class=\"language-bash\">pip3 install xtarfile[zstd] --use-pep517<\/code><\/pre>\n<p>\u4e0b\u8f7d cygwin \u7684\u8f6f\u4ef6\u5305<\/p>\n<pre><code class=\"language-bash\">python3 cyg2deb.py<\/code><\/pre>\n<p>\u5b89\u88c5 cygwin \u7684\u8f6f\u4ef6\u5305<\/p>\n<pre><code class=\"language-bash\">dpkg -i mingw64-x86_64-*<\/code><\/pre>\n<p>\u5728 QEMU \u6839\u76ee\u5f55\u521b\u5efa\u6587\u4ef6 x86_64-w64-mingw32.txt \uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-bash\">[binaries]\nc = &amp;#039;\/usr\/bin\/x86_64-w64-mingw32-gcc&amp;#039;\ncpp = &amp;#039;\/usr\/bin\/x86_64-w64-mingw32-g++&amp;#039;\nar = &amp;#039;\/usr\/bin\/x86_64-w64-mingw32-ar&amp;#039;\nstrip = &amp;#039;\/usr\/bin\/x86_64-w64-mingw32-strip&amp;#039;\npkgconfig = &amp;#039;\/usr\/bin\/x86_64-w64-mingw32-pkg-config&amp;#039;\nexe_wrapper = &amp;#039;wine&amp;#039;\n\n[host_machine]\nsystem = &amp;#039;windows&amp;#039;\ncpu_family = &amp;#039;x86_64&amp;#039;\ncpu = &amp;#039;x86_64&amp;#039;\nendian = &amp;#039;little&amp;#039;<\/code><\/pre>\n<p>\u83b7\u53d6 libslirp \uff1a<\/p>\n<pre><code class=\"language-bash\">git clone https:\/\/gitlab.freedesktop.org\/slirp\/libslirp.git<\/code><\/pre>\n<p>\u83b7\u53d6  virgl \u6765\u5b9e\u73b0 3D \u786c\u4ef6\u52a0\u901f\uff1a<\/p>\n<pre><code class=\"language-bash\">git clone https:\/\/gitlab.freedesktop.org\/virgl\/virglrenderer.git<\/code><\/pre>\n<p>\u521b\u5efa\u65b0\u76ee\u5f55\u6765\u5b58\u653e\u7f16\u8bd1\u540e\u4ea7\u751f\u7684 QEMU \u4f9d\u8d56\u7ec4\u4ef6\uff1a<\/p>\n<pre><code class=\"language-bash\">export CROSS_QEMU_DEPS=&amp;quot;\/home\/david921518\/data\/docker\/debian12\/cross-qemu-deps&amp;quot;\nmkdir -p $CROSS_QEMU_DEPS<\/code><\/pre>\n<p>\u5b89\u88c5 libslirp\uff1a<\/p>\n<pre><code class=\"language-bash\">cd libslirp\nmeson setup --cross-file ..\/x86_64-w64-mingw32.txt --prefix &amp;quot;$CROSS_QEMU_DEPS&amp;quot; build-mingw\/\nmeson compile -C build-mingw\ncd build-mingw\nninja install<\/code><\/pre>\n<p>\u5b89\u88c5 virgl<\/p>\n<pre><code class=\"language-bash\">cd ..\/..\/\ncd virglrenderer\nmeson setup --cross-file ..\/x86_64-w64-mingw32.txt --prefix &amp;quot;$CROSS_QEMU_DEPS&amp;quot; build-mingw\/\nmeson compile -C build-mingw\ncd build-mingw\nninja install<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u8bb0\u5f55\u5728 Debian 12 \u4e0a\u5229\u7528 docker \u8fdb\u884c QEMU W64 \u7684\u4ea4\u53c9\u7f16\u8bd1\u6b65\u9aa4 \u5b89\u88c5 docke [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pmpro_default_level":"","footnotes":""},"categories":[26],"tags":[],"class_list":["post-184","post","type-post","status-publish","format-standard","hentry","category-foss","pmpro-has-access"],"_links":{"self":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/comments?post=184"}],"version-history":[{"count":43,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/184\/revisions"}],"predecessor-version":[{"id":422,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/184\/revisions\/422"}],"wp:attachment":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/media?parent=184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/categories?post=184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/tags?post=184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}