我正在尝试在x86计算机上基于ARMv7容器运行Docker映像。根据此site,可以通过首先运行此容器来实现。
docker run --rm --privileged hypriot/qemu-register
此命令在Mac OS X和Ubuntu 19虚拟机(带有Windows 10主机)上有效。但是,当我尝试在CentOS 7和AWS A1 instances之一上运行时,收到消息standard_init_linux.go:211: exec user process caused "exec format error"
。 CentOS 7的CPU是Intel Core i7-8700K,AWS A1基于Graviton processor。
有人知道我在这里想念什么吗?
关于AWS A1实例的投诉是安装miniconda。我不确定是否有办法说“是”(继续安装),因为应该已经-b
标志让miniconda静默安装了。
Step 6/11 : RUN /bin/bash /tmp/miniconda.sh -b -p /opt/miniconda ---> Running in ab9b5fef6837 WARNING: Your processor does not appear to be an armv7l. This software was sepicically build for the Raspberry Pi 2 running raspbian wheezy (or above). Are sure you want to continue the installation? [yes|no] [no] >>> Aborting installation
答案 0 :(得分:4)
AWS A1实例确实支持运行Armv7二进制文件。使用可用的适用于A1的Ubuntu 18.04 AMI,在命令行上运行它:
import asyncio
import requests_html
from time import time
from bs4 import BeautifulSoup
async def fetch_content(url, session):
async with session.get(url, allow_redirects=True) as response:
data = await respone.read()
respone.html.render()
soup = BeautifulSoup(respone.html.html, 'lxml')
txt = soup.find_all('span', {'class': 'text'})
print(txt)
async def main():
url = 'http://quotes.toscrape.com/js/'
tasks = []
async with requests_html.AsyncHTMLSession() as session:
for i in range(10):
tasks.append(asyncio.create_task(fetch_content(url, session)))
await asyncio.gather(*tasks)
if __name__ == '__main__':
t0 = time()
asyncio.run(main())
print(time() - t0)
如果成功,则表明AMI和内核已构建为支持在64位平台上运行32位可执行文件。要测试此功能,请使用cat /boot/config-4.15.0-1043-aws | grep "CONFIG_COMPAT=y"
进行安装以获取最小的32位构建环境,创建可执行文件并在其上执行apt-get install gcc:armhf libc6:armhf
。您应该看到计算机列为ARM,而不是AArch64。执行也应该成功。
使用armv7映像测试docker在A1的Ubuntu 18.04 AMI上也可以立即使用。我通过readelf -h
进行了测试,然后使用bash进入了交互模式,并尝试安装Miniconda3。问题似乎与上面链接的Miniconda安装脚本有关。它在第58行上无条件尝试:
docker pull armhf/ubuntu:latest
Docker不会对if [[ `uname -m` != 'armv7l' ]]; then
echo -n "WARNING:
Your processor does not appear to be an armv7l. This software
was sepicically build for the Raspberry Pi 2 running raspbian wheezy
(or above).
Are sure you want to continue the installation? [yes|no]
[no] >>> "
read ans
if [[ ($ans != "yes") && ($ans != "Yes") && ($ans != "YES") &&
($ans != "y") && ($ans != "Y") ]]
then
echo "Aborting installation"
exit 2
fi
fi
返回的内容进行任何重写,它将在A1实例上看到AArch64并将跳到那里。注释掉此阻止将使您继续使用A1实例。
要使其在x86笔记本电脑上正常工作,您需要将uname -m
复制到Docker映像以启用仿真。我不确定,但是我会怀疑qemu-arm-static
仍不会返回Miniconda期望的正确机器类型。