uv: `uv pip install` fails from inside docker.

On my mac the install works just fine.

In docker though, I’m getting this error:

 => ERROR [builder  9/10] RUN --mount=type=ssh /root/.cargo/bin/uv pip install --system --no-cache -r requirements.txt   2.5s
------
 > [builder  9/10] RUN --mount=type=ssh /root/.cargo/bin/uv pip install --system --no-cache -r requirements.txt:
2.433 error: error sending request for url (https://northamerica-northeast2-python.pkg.dev/private-pypi-418615/ritual-pypi/simple/huggingface-hub/)
2.433   Caused by: client error (Connect)
2.433   Caused by: invalid peer certificate: BadSignature

This is my dockerfile:

# syntax=docker/dockerfile:1

# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/engine/reference/builder/

ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION}-slim as base

# Prevents Python from writing pyc files.
ENV PYTHONDONTWRITEBYTECODE=1

# Keeps Python from buffering stdout and stderr to avoid situations where
# the application crashes without emitting any logs due to buffering.
ENV PYTHONUNBUFFERED=1
ENV RUNTIME docker

WORKDIR /app

# Create a non-privileged user that the frenrug will run under.
# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
ARG UID=10001
RUN adduser \
    --disabled-password \
    --gecos "" \
    --home "/nonexistent" \
    --shell "/sbin/nologin" \
    --no-create-home \
    --uid "${UID}" \
    appuser

RUN apt-get update
RUN apt-get install -y curl

# Install UV
ADD --chmod=755 https://astral.sh/uv/install.sh /install.sh
RUN /install.sh && rm /install.sh

# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.cache/uv to speed up subsequent builds.
# Leverage a bind mount to requirements to avoid having to copy them into
# into this layer.
RUN --mount=type=cache,target=/root/.cache/uv \
    --mount=type=bind,source=requirements.txt,target=requirements.txt \
    /root/.cargo/bin/uv pip install --system -r requirements.txt

# Install some executables
RUN apt-get update \
    && apt-get install -y curl procps sysstat ifstat \
    && rm -rf /var/lib/apt/lists/*

# Copy the source code into the container.
COPY src/ src/
COPY entrypoint.sh .

# Run the application.
ENTRYPOINT ["/app/entrypoint.sh"]

Since I’m installing uv every time, it must use the latest version of uv. It’s using python’s official docker, so I’m assuming the certificates are outdated whenever installing from a debian environment?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 18
  • Comments: 17 (8 by maintainers)

Commits related to this issue

Most upvoted comments

It’s fixed for me now. Re-running the same docker image today works.

I’ll release a revert to that — it is indeed suspicious.

In my case, it fails on a different library in my requirements.txt file every time I run install.

Thanks for checking back in! Great to know it’s resolved.

I have the same issue, small workaround is by using yesterday version

RUN curl -LsSf https://astral.sh/uv/install.sh -o install.sh
RUN sed -i 's/0.1.43/0.1.42/g' install.sh
RUN sh install.sh

if anyone has a better way to set the version I would gladly take it

I’m using

ADD --chmod=755 https://github.com/astral-sh/uv/releases/download/0.1.42/uv-installer.sh /uv-installer.sh
RUN /uv-installer.sh && rm /uv-installer.sh

For now

Following @Max0u experiment, can install older version directly:

pip install uv==0.1.42