执行docker pull centos:7.9.2009 --platform=arm64,获取arm64架构版本centos7.9镜像
##拉取arm64架构版本centos7.9镜像
orangepi@orangepi5:~$ docker pull centos:7.9.2009 --platform=x86
Error response from daemon: "x86": unknown operating system or architecture: invalid argument
orangepi@orangepi5:~$ docker pull centos:7.9.2009 --platform=x86-64
7.9.2009: Pulling from library/centos
2d473b07cdd5: Pull complete
Digest: sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4
Status: Downloaded newer image for centos:7.9.2009
docker.io/library/centos:7.9.2009
执行docker inspect centos:7.9.2009,查看镜像版本信息
orangepi@orangepi5:~$ docker inspect centos:7.9.2009
[
{
"Id": "sha256:eeb6ee3f44bd0b5103bb561b4c16bcb82328cfe5809ab675bb17ab3a16c517c9",
"RepoTags": [
"centos:7.9.2009"
],
"RepoDigests": [
"centos@sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4"
],
"Parent": "",
"Comment": "",
"Created": "2021-09-15T18:20:23.99863383Z",
"Container": "5e4c7bfd35862166e9efd7532208300600114f0acff8f82fd537a57bdd523fe2",
"ContainerConfig": {
"Hostname": "5e4c7bfd3586",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"/bin/bash\"]"
],
"Image": "sha256:ba35a4b787c8f11e3b6ed9248c7663b4f27459e9715a1ace09f966259d5ebc3a",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"org.label-schema.build-date": "20201113",
"org.label-schema.license": "GPLv2",
"org.label-schema.name": "CentOS Base Image",
"org.label-schema.schema-version": "1.0",
"org.label-schema.vendor": "CentOS",
"org.opencontainers.image.created": "2020-11-13 00:00:00+00:00",
"org.opencontainers.image.licenses": "GPL-2.0-only",
"org.opencontainers.image.title": "CentOS Base Image",
"org.opencontainers.image.vendor": "CentOS"
}
},
"DockerVersion": "20.10.7",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/bash"
],
"Image": "sha256:ba35a4b787c8f11e3b6ed9248c7663b4f27459e9715a1ace09f966259d5ebc3a",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"org.label-schema.build-date": "20201113",
"org.label-schema.license": "GPLv2",
"org.label-schema.name": "CentOS Base Image",
"org.label-schema.schema-version": "1.0",
"org.label-schema.vendor": "CentOS",
"org.opencontainers.image.created": "2020-11-13 00:00:00+00:00",
"org.opencontainers.image.licenses": "GPL-2.0-only",
"org.opencontainers.image.title": "CentOS Base Image",
"org.opencontainers.image.vendor": "CentOS"
}
},
"Architecture": "amd64",
"Os": "linux",
"Size": 203936249,
"VirtualSize": 203936249,
"GraphDriver": {
"Data": {
"MergedDir": "/var/lib/docker/overlay2/bec7f1a9a08e909d2c915524405b9c830ad31f85a054bff3f484e176e9d969ce/merged",
"UpperDir": "/var/lib/docker/overlay2/bec7f1a9a08e909d2c915524405b9c830ad31f85a054bff3f484e176e9d969ce/diff",
"WorkDir": "/var/lib/docker/overlay2/bec7f1a9a08e909d2c915524405b9c830ad31f85a054bff3f484e176e9d969ce/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:174f5685490326fc0a1c0f5570b8663732189b327007e47ff13d2ca59673db02"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]
下载qemu-aarch64-static.tar.gz
#安装qemu-user-static
orangepi@orangepi5:~$ sudo apt-get install qemu binfmt-support qemu-user-static
拉取qemu-user-static镜像
##拉取qemu-user-static镜像
orangepi@orangepi5:~$ docker pull hectormolinero/qemu-user-static
启动qemu,注册虚拟机
orangepi@orangepi5:~$ docker run --rm --privileged hectormolinero/qemu-user-static
Setting /usr/bin/qemu-alpha-static as binfmt interpreter for alpha
Setting /usr/bin/qemu-arm-static as binfmt interpreter for arm
Setting /usr/bin/qemu-armeb-static as binfmt interpreter for armeb
Setting /usr/bin/qemu-sparc-static as binfmt interpreter for sparc
Setting /usr/bin/qemu-sparc32plus-static as binfmt interpreter for sparc32plus
Setting /usr/bin/qemu-sparc64-static as binfmt interpreter for sparc64
Setting /usr/bin/qemu-ppc-static as binfmt interpreter for ppc
Setting /usr/bin/qemu-ppc64-static as binfmt interpreter for ppc64
Setting /usr/bin/qemu-ppc64le-static as binfmt interpreter for ppc64le
Setting /usr/bin/qemu-m68k-static as binfmt interpreter for m68k
Setting /usr/bin/qemu-mips-static as binfmt interpreter for mips
Setting /usr/bin/qemu-mipsel-static as binfmt interpreter for mipsel
Setting /usr/bin/qemu-mipsn32-static as binfmt interpreter for mipsn32
Setting /usr/bin/qemu-mipsn32el-static as binfmt interpreter for mipsn32el
Setting /usr/bin/qemu-mips64-static as binfmt interpreter for mips64
Setting /usr/bin/qemu-mips64el-static as binfmt interpreter for mips64el
Setting /usr/bin/qemu-sh4-static as binfmt interpreter for sh4
Setting /usr/bin/qemu-sh4eb-static as binfmt interpreter for sh4eb
Setting /usr/bin/qemu-s390x-static as binfmt interpreter for s390x
Setting /usr/bin/qemu-aarch64-static as binfmt interpreter for aarch64
Setting /usr/bin/qemu-aarch64_be-static as binfmt interpreter for aarch64_be
Setting /usr/bin/qemu-hppa-static as binfmt interpreter for hppa
Setting /usr/bin/qemu-riscv32-static as binfmt interpreter for riscv32
Setting /usr/bin/qemu-riscv64-static as binfmt interpreter for riscv64
Setting /usr/bin/qemu-xtensa-static as binfmt interpreter for xtensa
Setting /usr/bin/qemu-xtensaeb-static as binfmt interpreter for xtensaeb
Setting /usr/bin/qemu-microblaze-static as binfmt interpreter for microblaze
Setting /usr/bin/qemu-microblazeel-static as binfmt interpreter for microblazeel
Setting /usr/bin/qemu-or1k-static as binfmt interpreter for or1k
Setting /usr/bin/qemu-hexagon-static as binfmt interpreter for hexagon
运行X86_64架构centos容器
##查看当前docker内镜像信息
orangepi@orangepi5:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hectormolinero/qemu-user-static latest 6db061469b82 11 months ago 63.7MB
1995chen/dnf centos6-2.0.2 b3548d6b4cd3 14 months ago 1.2GB
centos 7.9.2009 eeb6ee3f44bd 18 months ago 204MB
##运行X86架构centos,末尾eeb6ee3f44bd为容器ID
orangepi@orangepi5:~$ docker run -it -v /usr/bin/qemu-aarch64-static:/usr/bin/qemu-aarch64-static eeb6ee3f44bd
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
[root@f7c2b08e2825 /]# uname -m #运行后自动进入环境,检查架构可知为x86_64
x86_64
[root@f7c2b08e2825 /]# exit #退出虚拟环境
exit
orangepi@orangepi5:~$ uname -m
aarch64