0

I encountered an error while building a Docker image.
The command used was: 'docker build -t image_name .'.
The error message received was:

Step 10/16 : COPY ./ .
 ---> e94c25bf6e84
Step 11/16 : COPY --from=script_downloader /tmp/wait-for-it.sh .
 ---> e8cd760b47e0
Step 12/16 : RUN pip --version
 ---> Running in eb4b2c87846a
pip 23.0.1 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
Removing intermediate container eb4b2c87846a
 ---> 5530d11d5382
Step 13/16 : RUN chmod +x wait-for-it.sh
 ---> Running in 9cc684d95ca8
Removing intermediate container 9cc684d95ca8
 ---> 1ab35e20984f
Step 14/16 : RUN pip install poetry==1.5.1
 ---> Running in 18f915231962
Collecting poetry==1.5.1
  Downloading poetry-1.5.1-py3-none-any.whl (225 kB)
ERROR: Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 160, in exc_logging_wrapper
    status = run_func(*args)
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
    return func(self, options, args)
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 419, in run
    requirement_set = resolver.resolve(
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 92, in resolve
    result = self._result = resolver.resolve(
  File "/usr/local/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 481, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/usr/local/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 348, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "/usr/local/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 172, in _add_to_criteria
    if not criterion.candidates:
  File "/usr/local/lib/python3.8/site-packages/pip/_vendor/resolvelib/structs.py", line 151, in __bool__
    return bool(self._sequence)
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 155, in __bool__
    return any(self)
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/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.8/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 47, in _iter_built
    candidate = func()
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 206, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 297, in __init__
    super().__init__(
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 162, in __init__
    self.dist = self._prepare()
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 231, in _prepare
    dist = self._prepare_distribution()
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 308, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 491, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 536, in _prepare_linked_requirement
    local_file = unpack_url(
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 166, in unpack_url
    file = get_http_url(
  File "/usr/local/lib/python3.8/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.8/site-packages/pip/_internal/network/download.py", line 147, in __call__
    for chunk in chunks:
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/progress_bars.py", line 52, in _rich_progress_bar
    with progress:
  File "/usr/local/lib/python3.8/site-packages/pip/_vendor/rich/progress.py", line 1169, in __enter__
    self.start()
  File "/usr/local/lib/python3.8/site-packages/pip/_vendor/rich/progress.py", line 1160, in start
    self.live.start(refresh=True)
  File "/usr/local/lib/python3.8/site-packages/pip/_vendor/rich/live.py", line 132, in start
    self._refresh_thread.start()
  File "/usr/local/lib/python3.8/threading.py", line 852, in start
    _start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread

[notice] A new release of pip is available: 23.0.1 -> 23.1.2
[notice] To update, run: pip install --upgrade pip
The command '/bin/sh -c pip install poetry==1.5.1' returned a non-zero code: 2

Dockerfile content :

FROM alpine:3.18.0 as script_downloader

WORKDIR /tmp
RUN apk update && apk add wget
RUN wget https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh

FROM python:3.8-slim
LABEL version="1.0"
ENV PIP_NO_CACHE_DIR=off\
    PYTHONUNBUFFERED=1\
    PYTHONDONTWRITEBYTECODE=1\
    POETRY_HOME="/opt/poetry"\
    POETRY_CACHE_DIR='/var/cache/pypoetry'\
    POETRY_NO_INTERACTION=1

WORKDIR /app
COPY ./ .
COPY --from=script_downloader /tmp/wait-for-it.sh .
RUN chmod +x wait-for-it.sh
RUN pip install --upgrade pip
RUN pip install poetry==1.5.1
RUN poetry install

CMD ./wait-for-it.sh db:5432 -t 0 -- poetry run python manage.py collectstatic --no-input && poetry run python manage.py migrate && poetry run gunicorn -b 0.0.0.0:8000 app_name.wsgi

I get this error since 15 or 16/06.
Before, the build works fine.
I have also this error during the CI/CD pipeline of Gitlab.
And when I remove the pip install lines, the build works (RUN pip --version > 23.0.1).
I find it hard to believe that it could be from my system.
The build has been working for several years and all of a sudden it no longer works.
For what ?
This doesn't just happen on my computer, so I feel like the problem is somewhere else.

Guidev
  • 51
  • 9
  • 1
    The problem is the docker python version since they have upgraded it to 3.8.17. Change it to python:3.8.16-slim to fix the problem. – AutomaticHourglass Jun 23 '23 at 09:53
  • Yes and I also noticed that my python image was not suitable for the linux image used (python image for Debian). The problem is solved thank you ! – Guidev Jun 26 '23 at 07:24

0 Answers0