{"id":3000,"date":"2024-05-31T08:33:32","date_gmt":"2024-05-31T00:33:32","guid":{"rendered":"https:\/\/199604.com\/?p=3000"},"modified":"2025-08-19T11:00:48","modified_gmt":"2025-08-19T03:00:48","slug":"x86-or-amd%e5%b9%b3%e5%8f%b0%e5%88%a9%e7%94%a8-qemu-user-static-%e5%ae%9e%e7%8e%b0-arm64-%e5%b9%b3%e5%8f%b0-docker-%e9%95%9c%e5%83%8f%e7%9a%84%e8%bf%90%e8%a1%8c%e5%92%8c%e6%9e%84%e5%bb%ba","status":"publish","type":"post","link":"https:\/\/199604.com\/3000","title":{"rendered":"x86 or amd\u5e73\u53f0\u5229\u7528 qemu-user-static \u5b9e\u73b0 arm64 \u5e73\u53f0 docker \u955c\u50cf\u7684\u8fd0\u884c\u548c\u6784\u5efa"},"content":{"rendered":"<h1>x86 or amd\u5e73\u53f0\u5229\u7528 qemu-user-static \u5b9e\u73b0 arm64 \u5e73\u53f0 docker \u955c\u50cf\u7684\u8fd0\u884c\u548c\u6784\u5efa<\/h1>\n<h2>\u524d\u8a00<\/h2>\n<p>\u56e0\u56fd\u4ea7\u5316\u8d8b\u52bf\uff0c\u65b0\u7684\u4fe1\u521b\u73af\u5883CPU\u5927\u90e8\u5206\u4f7f\u7528ARM\u67b6\u6784\u3002\u56e0\u6682\u65e0arm\u73af\u5883\uff0c\u81ea\u5df1\u4e70 <code>arm<\/code> \u5e73\u53f0\u7684 <code>CPU<\/code>\uff0c\u8fd9\u4e2a\u6210\u672c\u7740\u5b9e\u5403\u4e0d\u6d88\uff0c\u4e8e\u662f\u5c1d\u8bd5 <code>x86<\/code> \u5e73\u53f0\u8fd0\u884c <code>arm<\/code> \u5e73\u53f0\u7684\u5bb9\u5668\u6765\u964d\u672c\u589e\u6548\u3002<\/p>\n<h2>\u5173\u4e8e docker \u7248\u672c<\/h2>\n<ul>\n<li><code>docker<\/code> \u8fd0\u884c\u5176\u4ed6\u5e73\u53f0\u5bb9\u5668\uff0c\u9700\u8981\u4f7f\u7528 <code>--platform<\/code> \u53c2\u6570\u6765\u6307\u5b9a\u5e73\u53f0<\/li>\n<li><code>docker 19.03.9<\/code> \u53ca\u4ee5\u4e0a\u7684\u7248\u672c\u624d\u652f\u6301 <code>--platform<\/code> \u53c2\u6570<\/li>\n<li>\u9ed8\u8ba4\u6ca1\u6709\u5f00\u542f <code>--platform<\/code> \u53c2\u6570\uff0c\u9700\u8981\u624b\u52a8\u5f00\u542f\u3002<\/li>\n<\/ul>\n<h3>\u5f00\u542fexperimental \u529f\u80fd\u914d\u7f6e\uff1a<\/h3>\n<p>\u53c2\u8003\uff1a<code>https:\/\/199604.com\/2865<\/code><\/p>\n<h3>\u67e5\u770b\u662f\u5426\u5f00\u542f experimental \u529f\u80fd<\/h3>\n<p><code>--platform<\/code> \u53c2\u6570\u9700\u8981 <code>experimental<\/code> \u4e3a <code>true<\/code>\uff0c\u901a\u8fc7\u4e0b\u9762\u7684\u547d\u4ee4\u53ef\u4ee5\u9a8c\u8bc1\u662f\u5426\u5f00\u542f:<\/p>\n<pre><code class=\"language-shell \">docker info | grep -i 'experimental'\n<\/code><\/pre>\n<h2>\u62c9\u53d6\u4e00\u4e2a arm \u5e73\u53f0\u7684\u5bb9\u5668\u6d4b\u8bd5<\/h2>\n<pre><code class=\"language-shell \">docker pull --platform arm64 debian:stable-slim\n\n#\u67e5\u770b\u955c\u50cf\u4f7f\u7528\u7684\u5e73\u53f0\ndocker inspect debian:stable-slim | grep -i 'architecture'\n<\/code><\/pre>\n<blockquote><p>\n  \u5982\u679c\u4e0d\u52a0 <code>--platform<\/code> \u53c2\u6570\uff0c\u9ed8\u8ba4\u62c9\u53d6\u81ea\u5df1\u5f53\u524d CPU \u5e73\u53f0\u7684\u955c\u50cf<\/p>\n<p>  \u5982\u679c\u672c\u5730\u6709\u76f8\u540c <code>tag<\/code> \u7684\u955c\u50cf\uff0c\u53ea\u662f\u5e73\u53f0\u4e0d\u540c\u7684\u60c5\u51b5\u4e0b\uff0c\u9700\u8981\u6ce8\u610f\u533a\u5206 <code>tag<\/code> \uff0c\u4e0d\u7136\u76f4\u63a5 <code>docker pull<\/code> \u5c31\u4f1a\u8986\u76d6\u6389\u4e4b\u524d\u7684\u955c\u50cf\uff0c\u4e4b\u524d\u7684\u955c\u50cf <code>tag<\/code> \u4f1a\u53d8\u4e3a <code>&lt;none&gt;<\/code>\n<\/p><\/blockquote>\n<h2>\u914d\u7f6eqemu-user-static\u4f9d\u8d56<\/h2>\n<h3>\u6ce8\u518c\u53ef\u652f\u6301\u7684\u67b6\u6784\u89e3\u91ca\u5668<\/h3>\n<pre><code class=\"language-shell \">docker run --rm \\\n--privileged \\\nmultiarch\/qemu-user-static:register \\\n--reset\n\n# \u6267\u884c\u6210\u529f\u540e\uff0c\u4f1a\u8fd4\u56de\u7c7b\u4f3c\u5982\u4e0b\u7684\u7ed3\u679c\u6765\u8868\u660e\u652f\u6301\u7684\u67b6\u6784\u89e3\u6790\u5668\nSetting \/usr\/bin\/qemu-alpha-static as binfmt interpreter for alpha\nSetting \/usr\/bin\/qemu-arm-static as binfmt interpreter for arm\nSetting \/usr\/bin\/qemu-armeb-static as binfmt interpreter for armeb\nSetting \/usr\/bin\/qemu-sparc-static as binfmt interpreter for sparc\nSetting \/usr\/bin\/qemu-sparc32plus-static as binfmt interpreter for sparc32plus\nSetting \/usr\/bin\/qemu-sparc64-static as binfmt interpreter for sparc64\nSetting \/usr\/bin\/qemu-ppc-static as binfmt interpreter for ppc\nSetting \/usr\/bin\/qemu-ppc64-static as binfmt interpreter for ppc64\nSetting \/usr\/bin\/qemu-ppc64le-static as binfmt interpreter for ppc64le\nSetting \/usr\/bin\/qemu-m68k-static as binfmt interpreter for m68k\nSetting \/usr\/bin\/qemu-mips-static as binfmt interpreter for mips\nSetting \/usr\/bin\/qemu-mipsel-static as binfmt interpreter for mipsel\nSetting \/usr\/bin\/qemu-mipsn32-static as binfmt interpreter for mipsn32\nSetting \/usr\/bin\/qemu-mipsn32el-static as binfmt interpreter for mipsn32el\nSetting \/usr\/bin\/qemu-mips64-static as binfmt interpreter for mips64\nSetting \/usr\/bin\/qemu-mips64el-static as binfmt interpreter for mips64el\nSetting \/usr\/bin\/qemu-sh4-static as binfmt interpreter for sh4\nSetting \/usr\/bin\/qemu-sh4eb-static as binfmt interpreter for sh4eb\nSetting \/usr\/bin\/qemu-s390x-static as binfmt interpreter for s390x\nSetting \/usr\/bin\/qemu-aarch64-static as binfmt interpreter for aarch64\nSetting \/usr\/bin\/qemu-aarch64_be-static as binfmt interpreter for aarch64_be\nSetting \/usr\/bin\/qemu-hppa-static as binfmt interpreter for hppa\nSetting \/usr\/bin\/qemu-riscv32-static as binfmt interpreter for riscv32\nSetting \/usr\/bin\/qemu-riscv64-static as binfmt interpreter for riscv64\nSetting \/usr\/bin\/qemu-xtensa-static as binfmt interpreter for xtensa\nSetting \/usr\/bin\/qemu-xtensaeb-static as binfmt interpreter for xtensaeb\nSetting \/usr\/bin\/qemu-microblaze-static as binfmt interpreter for microblaze\nSetting \/usr\/bin\/qemu-microblazeel-static as binfmt interpreter for microblazeel\nSetting \/usr\/bin\/qemu-or1k-static as binfmt interpreter for or1k\nSetting \/usr\/bin\/qemu-hexagon-static as binfmt interpreter for hexagon\n<\/code><\/pre>\n<blockquote><p>\n  \u4e0d\u6307\u5b9a CPU \u5e73\u53f0\uff0c\u4f7f\u7528 register \u6765\u6ce8\u518c\u53ef\u652f\u6301\u7684\u67b6\u6784\u89e3\u6790\u5668\n<\/p><\/blockquote>\n<h3>\u4e0b\u8f7d <code>qemu-aarch64-static<\/code><\/h3>\n<p><code>qemu-user-static<\/code>\u4e0b\u8f7d\u5730\u5740\uff1a<code>https:\/\/github.com\/multiarch\/qemu-user-static\/releases<\/code><\/p>\n<pre><code class=\"language-shell \">wget https:\/\/github.com\/multiarch\/qemu-user-static\/releases\/download\/v7.2.0-1\/qemu-aarch64-static\n\nchmod +x qemu-aarch64-static\n<\/code><\/pre>\n<h2>\u8fd0\u884c\u4e00\u4e2a arm \u5e73\u53f0\u7684\u5bb9\u5668<\/h2>\n<p>\u5728\u6ca1\u6709 <code>qemu-user-static<\/code> \u7684\u5e2e\u52a9\u4e0b\uff0c\u5355\u9760 <code>--platform<\/code> \u53c2\u6570\u662f\u65e0\u6cd5\u542f\u52a8\u975e\u672c\u673a\u5e73\u53f0\u7684\u955c\u50cf\u7684\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-shell \">docker run --platform arm64 -t --rm debian:stable-slim uname -m\n\n# \u8fd4\u56de\u7684\u62a5\u9519\u5982\u4e0b:\n# standard_init_linux.go:211: exec user process caused \"exec format error\"\n<\/code><\/pre>\n<p>\u9700\u8981\u542f\u52a8\u5bb9\u5668\u65f6\u5c06 <code>qemu-aarch64-static<\/code> \u5e26\u5165\u5230\u5bb9\u5668\u5185<\/p>\n<blockquote><p>\n  \u6ce8\u610f <code>qemu-aarch64-static<\/code> \u4e8c\u8fdb\u5236\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u53ef\u4ee5\u81ea\u5df1\u5f52\u7eb3\u5230\u6307\u5b9a\u7684\u8def\u5f84\uff0c\u53ea\u9700\u8981\u5e26\u5165\u5230\u5bb9\u5668\u5185\u7684 \/usr\/bin \u76ee\u5f55\u4e0b\u5c31\u597d\u4e86<\/p>\n<pre><code class=\"language-shell \">ll \/usr\/local\/sbin\/qemu-aarch64-static\n-rwxr-xr-x 1 root root 10402960 1\u6708  17 2023 \/usr\/local\/sbin\/qemu-aarch64-static\n<\/code><\/pre>\n<\/blockquote>\n<pre><code class=\"language-shell \">docker run -it \\\n--rm \\\n--platform arm64 \\\n-v \/usr\/local\/sbin\/qemu-aarch64-static:\/usr\/bin\/qemu-aarch64-static \\\ndebian:stable-slim \\\nuname -m\n\n# \u8fd4\u56de\u7ed3\u679c\naarch64\n<\/code><\/pre>\n<blockquote><p>\n  \u540c\u7406\uff0c\u53c2\u8bd5\u5176\u4ed6cpu\u67b6\u6784\u5e73\u53f0\u4e5f\u662f\u4e00\u6837\u4e0b\u8f7d<code>qemu-xxxx-static<\/code>\n<\/p><\/blockquote>\n<h2>\u6784\u5efa \u4e00\u4e2a arm64 \u955c\u50cf<\/h2>\n<ul>\n<li>\u51c6\u5907\u4e00\u4e2a <code>Dockerfile<\/code><\/li>\n<li>\u9700\u8981\u5c06 <code>qemu-aarch64-static<\/code> \u5e26\u5165\u5230\u5bb9\u5668\u5185\u7684 <code>\/usr\/bin<\/code> \u76ee\u5f55\u4e0b\u624d\u53ef\u4ee5\u5b9e\u73b0\u6784\u5efa<\/li>\n<li>\u4e0d\u7136\u4f1a\u8fd4\u56de <code>standard_init_linux.go:211: exec user process caused \"no such file or directory\"<\/code> \u8fd9\u6837\u7684\u62a5\u9519<\/li>\n<\/ul>\n<h3>Dockerfile<\/h3>\n<pre><code class=\"language-dockerfile \"># https:\/\/blog.csdn.net\/qq_34718871\/article\/details\/134218667\n# docker build --platform arm64 -t reg-hub.gzeport.com\/gzeport\/jdk\/debian-jdk11-arm:20240529 .\nFROM debian:stable-slim\n\nMAINTAINER guoliangjun&lt;post@199604.com&gt;\n# \u8bbe\u7f6eaarch64\u73af\u5883\nCOPY .\/qemu-aarch64-static \/usr\/bin\/qemu-aarch64-static\n\n# Support Chinese\nENV TIME_ZONE=\"Asia\/Shanghai\" \\\n    LANG=zh_CN.UTF-8 \\\n    LANGUAGE=zh_CN.UTF-8\n\n# \u5207\u6362apt\u6e90\u4e3a\u6e05\u534e\u6e90\uff0c\u5e76\u5b89\u88c5vim ping telnet\u547d\u4ee4\nRUN apt-get update &amp;&amp; apt install -y apt-transport-https ca-certificates \\\n    &amp;&amp; sed -i 's@deb.debian.org@mirrors.tuna.tsinghua.edu.cn@g' \/etc\/apt\/sources.list.d\/debian.sources \\\n    &amp;&amp; apt-get clean  \\\n    &amp;&amp; apt-get update  \\\n    &amp;&amp; apt-get install -y iputils-ping fontconfig tzdata ttf-dejavu* curl net-tools \\\n    &amp;&amp; cp \/usr\/share\/zoneinfo\/$TIME_ZONE \/etc\/localtime \\\n    &amp;&amp; echo $TIME_ZONE &gt; \/etc\/timezone \\\n    &amp;&amp; apt-get remove tzdata -y \\\n    &amp;&amp; addgroup --gid 2888 gzapps \\\n    &amp;&amp; adduser --uid 2888 --gid 2888 --home \/AppHome --disabled-password --gecos --no-create-home gzapps\n\n# Install JDK11 \u6ce8\u610f\u662flinux aarch64\nADD jdk-11.0.21_linux-aarch64_bin.tar.gz \/usr\/local\/jdk\nENV JAVA_HOME=\/usr\/local\/jdk\/jdk-11.0.21\nENV PATH=$JAVA_HOME\/bin:$PATH\n\nWORKDIR \/AppHome\nUSER gzapps\n<\/code><\/pre>\n<h3>\u5f00\u59cb\u6784\u5efa<\/h3>\n<pre><code class=\"language-shell \">docker build --platform arm64 -t reg-hub.gzeport.com\/gzeport\/jdk\/debian-jdk11-arm:20240529 .\n<\/code><\/pre>\n<h3>\u6784\u5efa\u5b8c\u6210\u540e<\/h3>\n<pre><code class=\"language-shell \">[root@localhost arm-x64]# docker inspect reg-hub.gzeport.com\/gzeport\/jdk\/debian-jdk11-arm:20240529 | grep -i 'architecture'\n        \"Architecture\": \"arm64\",\n<\/code><\/pre>\n<h2>\u65b9\u5f0f\u4e8c\uff1a\u4f7f\u7528buildx\u5728x86\u673a\u5668\u4e0a\u9762\u7f16\u8bd1arm64\u67b6\u6784\u7684Docker\u955c\u50cf<\/h2>\n<p>\u56e0\u4e3a Centos 7 \u7684\u5185\u6838\u592a\u8001\uff0c\u4f7f\u7528buildx\u6682\u65f6\u4e0d\u652f\u6301\uff0c\u53ea\u505a\u8bb0\u5f55<\/p>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/qn.199604.com\/typoraImg\/image-20240531083052806.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/qn.199604.com\/typoraImg\/image-20240531083052806.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"image-20240531083052806\" \/><\/div><\/p>\n<p>\u53c2\u8003\uff1a<\/p>\n<p>1.<code>https:\/\/blog.yasking.org\/a\/docker-multi-arch-with-buildx.html<\/code><\/p>\n<p>2.<code>https:\/\/www.cnblogs.com\/jinanxiaolaohu\/p\/17409839.html<\/code><\/p>\n<h2>\u53c2\u8003<\/h2>\n<p>1.<code>https:\/\/www.cnblogs.com\/chen2ha\/p\/17180287.html<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>x86 or amd\u5e73\u53f0\u5229\u7528 qemu-user-static \u5b9e\u73b0 arm64 \u5e73\u53f0 docker \u955c\u50cf\u7684\u8fd0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[332],"tags":[514,226],"class_list":["post-3000","post","type-post","status-publish","format-standard","hentry","category-docker","tag-arm","tag-docker"],"_links":{"self":[{"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/posts\/3000","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/comments?post=3000"}],"version-history":[{"count":1,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/posts\/3000\/revisions"}],"predecessor-version":[{"id":3001,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/posts\/3000\/revisions\/3001"}],"wp:attachment":[{"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/media?parent=3000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/categories?post=3000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/tags?post=3000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}