在 docker 工具箱中构建映像时无法进行 pip 安装

cannot pip install while building image in docker toolbox

提问人:user_stackoverflow 提问时间:10/6/2023 更新时间:10/6/2023 访问量:34

问:

我在使用 Docker Toolbox 构建 Docker 映像时遇到了此错误。pip版本:23.2.1 我正在使用 DockerToolbox-19.03.1 要求只有 fastapi==0.100.0 和 uvicorn==0.22.0 当我从现有容器(pip install fastapi==0.100.0)手动运行它时,它也以相同的错误结束

Step 1/5 : FROM python:3.11.4-slim-bookworm
 ---> 596e0d6b34df
Step 2/5 : COPY requirements.txt requirements.txt
 ---> 240e3a99abc1
Step 3/5 : RUN PIP_NO_CACHE_DIR=false     PIP_DISABLE_PIP_VERSION_CHECK=true
 pip install -r requirements.txt
 ---> Running in 3daacd971e8d
Collecting fastapi==0.100.0 (from -r requirements.txt (line 1))
  Downloading fastapi-0.100.0-py3-none-any.whl (65 kB)
ERROR: Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/cli/base_command.p
y", line 169, in exc_logging_wrapper
    status = run_func(*args)
             ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/cli/req_command.py
", line 248, in wrapper
    return func(self, options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/commands/install.p
y", line 377, in run
    requirement_set = resolver.resolve(
                      ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/resolution/resolve
lib/resolver.py", line 92, in resolve
    result = self._result = resolver.resolve(
                            ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers
.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers
.py", line 397, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "/usr/local/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers
.py", line 173, in _add_to_criteria
    if not criterion.candidates:
  File "/usr/local/lib/python3.11/site-packages/pip/_vendor/resolvelib/structs.p
y", line 156, in __bool__
    return bool(self._sequence)
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/resolution/resolve
lib/found_candidates.py", line 155, in __bool__
    return any(self)
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/resolution/resolve
lib/found_candidates.py", line 143, in <genexpr>
    return (c for c in iterator if id(c) not in self._incompatible_ids)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/resolution/resolve
lib/found_candidates.py", line 47, in _iter_built
    candidate = func()
                ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/resolution/resolve
lib/factory.py", line 206, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
                                       ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/resolution/resolve
lib/candidates.py", line 293, in __init__
    super().__init__(
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/resolution/resolve
lib/candidates.py", line 156, in __init__
    self.dist = self._prepare()
                ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/resolution/resolve
lib/candidates.py", line 225, in _prepare
    dist = self._prepare_distribution()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/resolution/resolve
lib/candidates.py", line 304, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/operations/prepare
.py", line 516, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/operations/prepare
.py", line 587, in _prepare_linked_requirement
    local_file = unpack_url(
                 ^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/operations/prepare
.py", line 166, in unpack_url
    file = get_http_url(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/operations/prepare
.py", line 107, in get_http_url
    from_path, content_type = download(link, temp_dir.path)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/network/download.p
y", line 147, in __call__
    for chunk in chunks:
  File "/usr/local/lib/python3.11/site-packages/pip/_internal/cli/progress_bars.
py", line 52, in _rich_progress_bar
    with progress:
  File "/usr/local/lib/python3.11/site-packages/pip/_vendor/rich/progress.py", l
ine 1169, in __enter__
    self.start()
  File "/usr/local/lib/python3.11/site-packages/pip/_vendor/rich/progress.py", l
ine 1160, in start
    self.live.start(refresh=True)
  File "/usr/local/lib/python3.11/site-packages/pip/_vendor/rich/live.py", line
132, in start
    self._refresh_thread.start()
  File "/usr/local/lib/python3.11/threading.py", line 957, in start
    _start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread
The command '/bin/sh -c PIP_NO_CACHE_DIR=false     PIP_DISABLE_PIP_VERSION_CHECK
=true     pip install -r requirements.txt' returned a non-zero code: 2

问题出在哪里? 先谢谢你

我已将 VM 的处理器设置为 2,将基本内存设置为 2048 mb

docker-build docker-工具箱

评论


答: 暂无答案