Docker构建失败pip3安装redis

dnph8jn4  于 2022-12-03  发布在  Docker
关注(0)|答案(1)|浏览(244)

我使用下面的docker构建器交叉编译一个基于Alpine的docker映像:

Name:   builder_name
Driver: docker-container

Nodes:
Name:      builder_name0
Endpoint:  unix:///var/run/docker.sock
Status:    running
Buildkit:  v0.10.5
Platforms: linux/arm/v7*, linux/amd64*, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/386

现在,运行命令时

$ docker buildx build --rm --platform linux/arm/v7 -t container_name:latest --file ./Dockerfile --load ..

运行时生成器无法安装redis-py

RUN pip3 install redis

以下是错误消息:

------                                                                                              
 > [stage-1  8/37] RUN pip3 install redis:                                                          
#0 15.00 ERROR: Exception:
#0 15.00 Traceback (most recent call last):
#0 15.00   File "/usr/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper
#0 15.00     status = run_func(*args)
#0 15.00   File "/usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
#0 15.00     return func(self, options, args)
#0 15.00   File "/usr/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 287, in run
#0 15.00     session = self.get_default_session(options)
#0 15.00   File "/usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 75, in get_default_session
#0 15.00     self._session = self.enter_context(self._build_session(options))
#0 15.00   File "/usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 89, in _build_session
#0 15.00     session = PipSession(
#0 15.00   File "/usr/lib/python3.10/site-packages/pip/_internal/network/session.py", line 282, in __init__
#0 15.00     self.headers["User-Agent"] = user_agent()
#0 15.00   File "/usr/lib/python3.10/site-packages/pip/_internal/network/session.py", line 122, in user_agent
#0 15.00     linux_distribution = distro.name(), distro.version(), distro.codename()
#0 15.00   File "/usr/lib/python3.10/site-packages/pip/_vendor/distro/distro.py", line 345, in version
#0 15.00     return _distro.version(pretty, best)
#0 15.00   File "/usr/lib/python3.10/site-packages/pip/_vendor/distro/distro.py", line 874, in version
#0 15.00     self.uname_attr("release"),
#0 15.00   File "/usr/lib/python3.10/site-packages/pip/_vendor/distro/distro.py", line 1059, in uname_attr
#0 15.00     return self._uname_info.get(attribute, "")
#0 15.00   File "/usr/lib/python3.10/functools.py", line 981, in __get__
#0 15.00     val = self.func(instance)
#0 15.00   File "/usr/lib/python3.10/site-packages/pip/_vendor/distro/distro.py", line 1173, in _uname_info
#0 15.00     stdout = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
#0 15.00   File "/usr/lib/python3.10/subprocess.py", line 420, in check_output
#0 15.00     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
#0 15.00   File "/usr/lib/python3.10/subprocess.py", line 524, in run
#0 15.00     raise CalledProcessError(retcode, process.args,
#0 15.00 subprocess.CalledProcessError: Command '('uname', '-rs')' returned non-zero exit status 1.
#0 15.01 Traceback (most recent call last):
#0 15.01   File "/usr/bin/pip3", line 33, in <module>
#0 15.01     sys.exit(load_entry_point('pip==22.1.1', 'console_scripts', 'pip3')())
#0 15.01   File "/usr/lib/python3.10/site-packages/pip/_internal/cli/main.py", line 70, in main
#0 15.01     return command.main(cmd_args)
#0 15.01   File "/usr/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 101, in main
#0 15.01     return self._main(args)
#0 15.01   File "/usr/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 223, in _main
#0 15.02     self.handle_pip_version_check(options)
#0 15.02   File "/usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 144, in handle_pip_version_check
#0 15.02     session = self._build_session(
#0 15.02   File "/usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 89, in _build_session
#0 15.02     session = PipSession(
#0 15.02   File "/usr/lib/python3.10/site-packages/pip/_internal/network/session.py", line 282, in __init__
#0 15.02     self.headers["User-Agent"] = user_agent()
#0 15.02   File "/usr/lib/python3.10/site-packages/pip/_internal/network/session.py", line 122, in user_agent
#0 15.02     linux_distribution = distro.name(), distro.version(), distro.codename()
#0 15.02   File "/usr/lib/python3.10/site-packages/pip/_vendor/distro/distro.py", line 345, in version
#0 15.02     return _distro.version(pretty, best)
#0 15.02   File "/usr/lib/python3.10/site-packages/pip/_vendor/distro/distro.py", line 874, in version
#0 15.02     self.uname_attr("release"),
#0 15.02   File "/usr/lib/python3.10/site-packages/pip/_vendor/distro/distro.py", line 1059, in uname_attr
#0 15.03     return self._uname_info.get(attribute, "")
#0 15.03   File "/usr/lib/python3.10/functools.py", line 981, in __get__
#0 15.03     val = self.func(instance)
#0 15.03   File "/usr/lib/python3.10/site-packages/pip/_vendor/distro/distro.py", line 1173, in _uname_info
#0 15.04     stdout = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
#0 15.04   File "/usr/lib/python3.10/subprocess.py", line 420, in check_output
#0 15.04     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
#0 15.04   File "/usr/lib/python3.10/subprocess.py", line 524, in run
#0 15.04     raise CalledProcessError(retcode, process.args,
#0 15.04 subprocess.CalledProcessError: Command '('uname', '-rs')' returned non-zero exit status 1.
------

有人遇到过这样的问题吗?我尝试到处搜索uname -rs返回非零状态的情况,但什么都找不到。

rjee0c15

rjee0c151#

如果未解决此问题,请参阅https://github.com/nicolabs/nicobot/issues/60
最后一条评论为我解决了这个问题:

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

相关问题