uv: `uv pip install` private pypi repo doesn't work when used in docker by default

uv:0.4.24 linux, opensuse

Hi, there seems to be a difference how pip and uv searches for private pypi repos in docker, outside of docker both work just fine.

When I am using pip install, everything is installed properly but with uv it fails with the following error

#14 0.500 DEBUG Transient request failure for https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/alembic/, retrying: error sending request for url (https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/alembic/)
#14 0.500   Caused by: client error (Connect)
#14 0.500   Caused by: dns error: failed to lookup address information: Name does not resolve
#14 0.500   Caused by: failed to lookup address information: Name does not resolve
Here is the full dockerfile
    FROM ghcr.io/astral-sh/uv:0.4.24 AS uv

    FROM python:3.9.20-slim-bookworm
    
    # create virtual env to be copied into runtime image later
    RUN python -m venv /opt/venv
    
    ENV PATH="/opt/venv/bin:$PATH"
    
    COPY --from=uv /uv /bin/uv
    
    COPY requirements.txt ./
    
    RUN --mount=type=secret,id=netrc,required,target=/root/.netrc pip install --verbose -r requirements.txt
    
    # again the same for the uv
    
    RUN rm -rf /opt/venv
    
    # create virtual env to be copied into runtime image later
    RUN python -m venv /opt/venv
    
    RUN --mount=type=secret,id=netrc,required,target=/root/.netrc uv pip install -v -r requirements.txt

Here is the output for the docker build command. Both pip and uv pip. Removed the unrelated layers to make it a little bit shorter

docker build --secret id=netrc,src=$HOME/.netrc --progress=plain --no-cache . | tee build.log

#8 [stage-1 2/8] RUN python -m venv /opt/venv
#8 DONE 3.4s

#9 [stage-1 3/8] COPY --from=uv /uv /bin/uv
#9 DONE 2.8s

#10 [stage-1 4/8] COPY requirements.txt ./
#10 DONE 0.2s

#11 [stage-1 5/8] RUN --mount=type=secret,id=netrc,required,target=/root/.netrc pip install --verbose -r requirements.txt
#11 0.561 Using pip 23.0.1 from /opt/venv/lib/python3.9/site-packages/pip (python 3.9)
#11 0.591 Looking in indexes: https://pypi.org/simple, https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple
#11 1.288 Collecting alembic==1.13.3
#11 1.502   Downloading alembic-1.13.3-py3-none-any.whl (233 kB)
#11 1.663      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 233.2/233.2 kB 1.4 MB/s eta 0:00:00
#11 2.255 Collecting tm-redis==2.1.1
#11 2.539   Downloading https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/files/6cc2163fbb385478d9f1319f62b351cafa2965d8b296c5e5cb118ac7270dc8bd/tm_redis-2.1.1-py3-none-any.whl (5.5 kB)
#11 3.977 Collecting SQLAlchemy>=1.3.0
#11 4.078   Downloading SQLAlchemy-2.0.36-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB)
#11 4.930      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.1/3.1 MB 3.6 MB/s eta 0:00:00
#11 5.442 Collecting Mako
#11 5.499   Downloading Mako-1.3.6-py3-none-any.whl (78 kB)
#11 5.529      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.6/78.6 kB 2.5 MB/s eta 0:00:00
#11 5.810 Collecting typing-extensions>=4
#11 5.866   Downloading typing_extensions-4.12.2-py3-none-any.whl (37 kB)
#11 6.245 Collecting redis<5.0.0,>=4.4.0
#11 6.303   Downloading redis-4.6.0-py3-none-any.whl (241 kB)
#11 6.350      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 241.1/241.1 kB 6.0 MB/s eta 0:00:00
#11 7.091 Collecting pydantic<3
#11 7.157   Downloading pydantic-2.9.2-py3-none-any.whl (434 kB)
#11 7.229      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 434.9/434.9 kB 6.1 MB/s eta 0:00:00
#11 7.502 Collecting annotated-types>=0.6.0
#11 7.558   Downloading annotated_types-0.7.0-py3-none-any.whl (13 kB)
#11 10.29 Collecting pydantic-core==2.23.4
#11 10.35   Downloading pydantic_core-2.23.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB)
#11 10.82      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 4.4 MB/s eta 0:00:00
#11 11.29 Collecting async-timeout>=4.0.2
#11 11.34   Downloading async_timeout-4.0.3-py3-none-any.whl (5.7 kB)
#11 12.24 Collecting greenlet!=0.4.17
#11 12.29   Downloading greenlet-3.1.1-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (597 kB)
#11 12.40      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 597.4/597.4 kB 5.7 MB/s eta 0:00:00
#11 12.95 Collecting MarkupSafe>=0.9.2
#11 13.02   Downloading MarkupSafe-3.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (20 kB)
#11 13.12 Installing collected packages: typing-extensions, MarkupSafe, greenlet, async-timeout, annotated-types, SQLAlchemy, redis, pydantic-core, Mako, pydantic, alembic, tm-redis
#11 14.23   changing mode of /opt/venv/bin/mako-render to 755
#11 14.55   changing mode of /opt/venv/bin/alembic to 755
#11 14.59 Successfully installed Mako-1.3.6 MarkupSafe-3.0.2 SQLAlchemy-2.0.36 alembic-1.13.3 annotated-types-0.7.0 async-timeout-4.0.3 greenlet-3.1.1 pydantic-2.9.2 pydantic-core-2.23.4 redis-4.6.0 tm-redis-2.1.1 typing-extensions-4.12.2
#11 14.86 
#11 14.86 [notice] A new release of pip is available: 23.0.1 -> 24.2
#11 14.86 [notice] To update, run: pip install --upgrade pip
#11 DONE 17.0s

#12 [stage-1 6/8] RUN rm -rf /opt/venv
#12 DONE 0.8s

#13 [stage-1 7/8] RUN python -m venv /opt/venv
#13 DONE 4.2s

#14 [stage-1 8/8] RUN --mount=type=secret,id=netrc,required,target=/root/.netrc uv pip install -v -r requirements.txt
#14 0.450 DEBUG uv 0.4.24
#14 0.451 DEBUG Searching for default Python interpreter in system path
#14 0.494 DEBUG Found `cpython-3.9.20-linux-x86_64-gnu` at `/opt/venv/bin/python` (search path)
#14 0.494 Using Python 3.9.20 environment at /opt/venv
#14 0.494 DEBUG Acquired lock for `/opt/venv`
#14 0.494 DEBUG At least one requirement is not satisfied: tm-redis==2.1.1
#14 0.495 DEBUG Using request timeout of 30s
#14 0.495 DEBUG Solving with installed Python version: 3.9.20
#14 0.495 DEBUG Solving with target Python version: >=3.9.20
#14 0.495 DEBUG Adding direct dependency: alembic==1.13.3
#14 0.495 DEBUG Adding direct dependency: tm-redis==2.1.1
#14 0.495 DEBUG No cache entry for: https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/alembic/
#14 0.496 DEBUG No cache entry for: https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/tm-redis/
#14 0.500 DEBUG Transient request failure for https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/alembic/, retrying: error sending request for url (https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/alembic/)
#14 0.500   Caused by: client error (Connect)
#14 0.500   Caused by: dns error: failed to lookup address information: Name does not resolve
#14 0.500   Caused by: failed to lookup address information: Name does not resolve
#14 0.500 DEBUG Transient request failure for https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/tm-redis/, retrying: error sending request for url (https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/tm-redis/)
#14 0.500   Caused by: client error (Connect)
#14 0.500   Caused by: dns error: failed to lookup address information: Name does not resolve
#14 0.500   Caused by: failed to lookup address information: Name does not resolve
#14 0.672 DEBUG Transient request failure for https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/alembic/, retrying: error sending request for url (https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/alembic/)
#14 0.672   Caused by: client error (Connect)
#14 0.672   Caused by: dns error: failed to lookup address information: Name does not resolve
#14 0.672   Caused by: failed to lookup address information: Name does not resolve
#14 1.252 DEBUG Transient request failure for https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/tm-redis/, retrying: error sending request for url (https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/tm-redis/)
#14 1.252   Caused by: client error (Connect)
#14 1.252   Caused by: dns error: failed to lookup address information: Name does not resolve
#14 1.252   Caused by: failed to lookup address information: Name does not resolve
#14 1.801 DEBUG Transient request failure for https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/alembic/, retrying: error sending request for url (https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/alembic/)
#14 1.801   Caused by: client error (Connect)
#14 1.801   Caused by: dns error: failed to lookup address information: Name does not resolve
#14 1.801   Caused by: failed to lookup address information: Name does not resolve
#14 1.837 DEBUG Transient request failure for https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/alembic/, retrying: error sending request for url (https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/alembic/)
#14 1.837   Caused by: client error (Connect)
#14 1.837   Caused by: dns error: failed to lookup address information: Name does not resolve
#14 1.837   Caused by: failed to lookup address information: Name does not resolve
#14 1.837 DEBUG Released lock at `/opt/venv/.lock`
#14 1.837 error: Could not connect, are you offline?
#14 1.837   Caused by: Request failed after 3 retries
#14 1.837   Caused by: error sending request for url (https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/alembic/)
#14 1.837   Caused by: client error (Connect)
#14 1.837   Caused by: dns error: failed to lookup address information: Name does not resolve
#14 1.837   Caused by: failed to lookup address information: Name does not resolve
#14 ERROR: process "/bin/sh -c uv pip install -v -r requirements.txt" did not complete successfully: exit code: 2
------
 > [stage-1 8/8] RUN --mount=type=secret,id=netrc,required,target=/root/.netrc uv pip install -v -r requirements.txt:
1.837   Caused by: client error (Connect)
1.837   Caused by: dns error: failed to lookup address information: Name does not resolve
1.837   Caused by: failed to lookup address information: Name does not resolve
1.837 DEBUG Released lock at `/opt/venv/.lock`
1.837 error: Could not connect, are you offline?
1.837   Caused by: Request failed after 3 retries
1.837   Caused by: error sending request for url (https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple/alembic/)
1.837   Caused by: client error (Connect)
1.837   Caused by: dns error: failed to lookup address information: Name does not resolve
1.837   Caused by: failed to lookup address information: Name does not resolve
------
Dockerfile:23
--------------------
  21 |     RUN python -m venv /opt/venv
  22 |     
  23 | >>> RUN --mount=type=secret,id=netrc,required,target=/root/.netrc uv pip install -v -r requirements.txt
  24 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c uv pip install -v -r requirements.txt" did not complete successfully: exit code: 2
the installed requirements file looks like this
--index-url https://pypi.org/simple
--extra-index-url https://gitlab.tmloc.com/api/v4/groups/7/-/packages/pypi/simple

alembic==1.13.3

tm-redis==2.1.1

Do you have any idea what could be the issue?

It can be workarounded by manually writing the DNS ip addresses to /etc/docker/daemon.json but I guess that it should behave the same as pip 🤷

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 15
  • Comments: 25 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I have an interesting finding:

Doing this in the Dockerfile based on python:3.11-slim:

COPY --from=ghcr.io/astral-sh/uv:0.4.24 /uv /bin/uv

Then result of a command using a private registry fails like this:

# uv pip install --no-cache -i http://devpi:3141/dev/+simple transitions
Using Python 3.11.11 environment at: /opt/venv
⠼ Resolving dependencies...                                                                                                                                                                                        error: Failed to fetch: `http://devpi:3141/mycompany/dev/+simple/transitions/`
  Caused by: Could not connect, are you offline?
  Caused by: Request failed after 3 retries
  Caused by: error sending request for url (http://devpi:3141/dev/+simple/transitions/)
  Caused by: client error (Connect)
  Caused by: dns error: failed to lookup address information: Name does not resolve
  Caused by: failed to lookup address information: Name does not resolve

But if instead we install uv with pip like this:

RUN pip install --no-cache-dir uv==0.4.24

Then there is no issue. The same behaviour is seen from copying from ghcr.io/astral-sh/uv:latest or ghcr.io/astral-sh/uv:debian.

There is visibly something incompatible between python-slim and those uv executable (having a different size and checksum) compared to the version installed with pip.

The “fun” think is that for one of our coworkers (and only one), it works without problem, without any obvious difference in the setup…

It seems like musl 1.2.4 came with some non-trivial breaking changes that rust is struggling to integrate. There’s been a branch open for 1.2.5 for a year:

As I understand it, musl libc had a bunch of aliases for symbols that the libc crate was using and the musl team decided to drop because they were causing havoc with some C++ projects. The libc crate was changed to use the proper symbol names (released in 0.2.145 almost two years ago), but various crates in the ecosystem (like getrandom) were on such old versions of the libc crate that tons of things broke when bumping to musl 1.2.4+, as of July 2024.

I’ll poke upstream to see if progress can be made on the issue.


See also, other discussion of this in the ecosystem:

Sorry I’m not sure how uv could fix this or why it’s different— we’re just using a standard reqwest network stack.

Using pip install works with no issue, apt install, every other command works except for UV Including UV pip install and UV python install

I think it is related to UV somehow