pixi icon indicating copy to clipboard operation
pixi copied to clipboard

Spurious connection errors in containers

Open ctcjab opened this issue 1 year ago • 4 comments

Checks

  • [x] I have checked that this issue has not already been reported.

  • [x] I have confirmed this bug exists on the latest version of pixi, using pixi --version.

Reproducible example

I can reliably reproduce this on my machine:

FROM fedora:latest
RUN curl -sI https://conda.anaconda.org  # this domain resolves fine via curl
RUN curl -fsSL https://pixi.sh/install.sh | bash  # curl resolves pixi.sh fine too
RUN ~/.pixi/bin/pixi global install shellcheck  # dns error for conda.anaconda.org
❯ docker build --platform linux/amd64 -t testing:dev .
[+] Building 45.1s (7/7) FINISHED                                                    docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                 0.0s
 => => transferring dockerfile: 268B                                                                 0.0s
 => [internal] load metadata for docker.io/library/fedora:latest                                     0.0s
 => [internal] load .dockerignore                                                                    0.0s
 => => transferring context: 2B                                                                      0.0s
 => [1/4] FROM docker.io/library/fedora:latest                                                       0.0s
 => CACHED [2/4] RUN curl -sI https://conda.anaconda.org  # this domain resolves fine via curl       0.0s
 => CACHED [3/4] RUN curl -fsSL https://pixi.sh/install.sh | bash  # curl resolves other domains fi  0.0s
 => ERROR [4/4] RUN ~/.pixi/bin/pixi global install shellcheck                                      45.1s
------
 > [4/4] RUN ~/.pixi/bin/pixi global install shellcheck:
45.10 Error:
45.10   × Couldn't install shellcheck
45.10   ├─▶ Request failed after 3 retries
45.10   ├─▶ error sending request for url (https://conda.anaconda.org/conda-forge/
45.10   │   linux-64/repodata.json)
45.10   ├─▶ client error (Connect)
45.10   ├─▶ dns error: failed to lookup address information: Try again
45.10   ╰─▶ failed to lookup address information: Try again
45.10
------
Dockerfile:4
--------------------
   2 |     RUN curl -sI https://conda.anaconda.org  # this domain resolves fine via curl
   3 |     RUN curl -fsSL https://pixi.sh/install.sh | bash  # curl resolves other domains fine
   4 | >>> RUN ~/.pixi/bin/pixi global install shellcheck
   5 |
--------------------
ERROR: failed to solve: process "/bin/sh -c ~/.pixi/bin/pixi global install shellcheck" did not complete successfully: exit code: 1

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/y9sz9su2jl4gm2zalq0d246nw

I tried with other base images (ubuntu:latest, alpine:latest, etc.) and reproduced with all of them.

This is using latest pixi (0.41.4) and latest Docker Desktop for macOS (4.38.0) on my work laptop, which auto-connects to my company VPN. I realize the VPN makes this harder to reproduce, but hopefully this Dockerfile provides a clue.

If I replace the pixi global install call with a pixi self-update call, it also fails, though the error does not mention DNS:

  => ERROR [4/5] RUN ~/.pixi/bin/pixi self-update                                      5.3s
------
 > [4/5] RUN ~/.pixi/bin/pixi self-update
5.251 Error:
5.255   × URL: https://github.com/prefix-dev/pixi/releases/latest. Request failed:
5.255   │ error sending request for url (https://github.com/prefix-dev/pixi/
5.255   │ releases/latest)

If I run pixi from my host system (macOS), it works fine:

❯ pixi global install shellcheck
Global environments as specified in '/Users/joshua.bronson/.pixi/manifests/pixi-global.toml'
└── shellcheck: 0.10.0 (installed)
    └─ exposes: shellcheck

❯ pixi --version
pixi 0.41.4

Issue description

pixi fails to connect when running inside a container though all other tested programs in the container (curl, wget, etc.) are able to.

Expected behavior

pixi is able to connect to whatever curl and other programs are able to connect to.

ctcjab avatar Feb 22 '25 19:02 ctcjab

hey! thanks for reporting this

could you please run the following commands in your container?

strace -f -e trace=network ~/.pixi/bin/pixi global install shellcheck and

cat /etc/resolv.conf to show me the DNS used by your container

maybe try to add:

RUN apt-get install ca-certificates openssl

It will help me understand the root issue. thanks!

nichtmacho avatar Feb 24 '25 08:02 nichtmacho

I'm running the Linux container inside macOS so I can't run strace in it (strace: test_ptrace_get_syscall_info: PTRACE_TRACEME: Function not implemented), but here's the resolve.conf:

root@94421fcd9a29:/# cat /etc/resolv.conf
# Generated by Docker Engine.
# This file can be edited; Docker Engine will not make further changes once it
# has been modified.

nameserver 192.168.65.7

# Based on host file: '/etc/resolv.conf' (legacy)
# Overrides: []

And here is some more verbose output, in case that helps:

root@94421fcd9a29:/# curl --verbose -I https://conda.anaconda.org
* Host conda.anaconda.org:443 was resolved.
* IPv6: (none)
* IPv4: 104.19.144.37, 104.19.145.37
*   Trying 104.19.144.37:443...
* Connected to conda.anaconda.org (104.19.144.37) port 443
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / X25519 / id-ecPublicKey
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=anaconda.org
*  start date: Feb 21 22:02:37 2025 GMT
*  expire date: May 22 22:02:36 2025 GMT
*  subjectAltName: host "conda.anaconda.org" matched cert's "*.anaconda.org"
*  issuer: C=US; O=Let's Encrypt; CN=E5
*  SSL certificate verify ok.
*   Certificate level 0: Public key type EC/prime256v1 (256/128 Bits/secBits), signed using ecdsa-with-SHA384
*   Certificate level 1: Public key type EC/secp384r1 (384/192 Bits/secBits), signed using sha256WithRSAEncryption
*   Certificate level 2: Public key type RSA (4096/152 Bits/secBits), signed using sha256WithRSAEncryption
* using HTTP/2
* [HTTP/2] [1] OPENED stream for https://conda.anaconda.org/
* [HTTP/2] [1] [:method: HEAD]
* [HTTP/2] [1] [:scheme: https]
* [HTTP/2] [1] [:authority: conda.anaconda.org]
* [HTTP/2] [1] [:path: /]
* [HTTP/2] [1] [user-agent: curl/8.5.0]
* [HTTP/2] [1] [accept: */*]
> HEAD / HTTP/2
> Host: conda.anaconda.org
> User-Agent: curl/8.5.0
> Accept: */*
>
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
< HTTP/2 302
HTTP/2 302
< date: Tue, 25 Feb 2025 22:14:19 GMT
date: Tue, 25 Feb 2025 22:14:19 GMT
< content-type: text/html; charset=utf-8
content-type: text/html; charset=utf-8
< location: https://anaconda.org/
location: https://anaconda.org/
< cf-ray: 917b0c340f54800f-IAD
cf-ray: 917b0c340f54800f-IAD
< cf-cache-status: DYNAMIC
cf-cache-status: DYNAMIC
< strict-transport-security: max-age=15552000
strict-transport-security: max-age=15552000
< content-security-policy: frame-ancestors 'self';
content-security-policy: frame-ancestors 'self';
< referrer-policy: no-referrer
referrer-policy: no-referrer
< x-content-type-options: nosniff
x-content-type-options: nosniff
< x-download-options: noopen
x-download-options: noopen
< set-cookie: __cf_bm=1.aI5REsCpbZZJyHluMkCQv6ncK1DQCgBnv_UGuy4zo-1740521659-1.0.1.1-EcI.QzGM4V.hrgyK8xj3cPLnuhtokpU9wv1nKTYw1Bw1pieh9_vLuCnrtpG5F97St2._f.pzUWKGPwWy_D6iurfI0a02nyc9L4OR5JHstZM; path=/; expires=Tue, 25-Feb-25 22:44:19 GMT; domain=.anaconda.org; HttpOnly; Secure; SameSite=None
set-cookie: __cf_bm=1.aI5REsCpbZZJyHluMkCQv6ncK1DQCgBnv_UGuy4zo-1740521659-1.0.1.1-EcI.QzGM4V.hrgyK8xj3cPLnuhtokpU9wv1nKTYw1Bw1pieh9_vLuCnrtpG5F97St2._f.pzUWKGPwWy_D6iurfI0a02nyc9L4OR5JHstZM; path=/; expires=Tue, 25-Feb-25 22:44:19 GMT; domain=.anaconda.org; HttpOnly; Secure; SameSite=None
< server: cloudflare
server: cloudflare

<
* Connection #0 to host conda.anaconda.org left intact

root@94421fcd9a29:/# pixi --verbose global install shellcheck
 WARN reqwest_retry::middleware: Retry attempt #0. Sleeping 100.045312ms before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #0. Sleeping 944.492352ms before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #0. Sleeping 149.231429ms before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #0. Sleeping 625.579354ms before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #0. Sleeping 448.72061ms before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #0. Sleeping 474.330237ms before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #1. Sleeping 1.048623449s before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #1. Sleeping 1.678746511s before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #1. Sleeping 847.449055ms before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #1. Sleeping 1.447725492s before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #1. Sleeping 1.557513089s before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #1. Sleeping 1.961350491s before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #2. Sleeping 3.812997501s before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #2. Sleeping 592.274652ms before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #2. Sleeping 2.474690049s before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #2. Sleeping 2.959979586s before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #2. Sleeping 1.249466956s before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #2. Sleeping 732.046847ms before the next attempt
 WARN rattler_repodata_gateway::fetch: failed to perform HEAD request on 'https://conda.anaconda.org/conda-forge/linux-64/repodata.json.bz2': Request failed after 3 retries. Assuming its unavailable..
 WARN rattler_repodata_gateway::fetch: failed to perform HEAD request on 'https://conda.anaconda.org/conda-forge/linux-64/repodata.json.zst': Request failed after 3 retries. Assuming its unavailable..
 WARN rattler_repodata_gateway::fetch: failed to perform HEAD request on 'https://conda.anaconda.org/conda-forge/noarch/repodata.json.bz2': Request failed after 3 retries. Assuming its unavailable..
 WARN rattler_repodata_gateway::fetch: failed to perform HEAD request on 'https://conda.anaconda.org/conda-forge/noarch/repodata.jlap': Request failed after 3 retries. Assuming its unavailable..
 WARN rattler_repodata_gateway::fetch: failed to perform HEAD request on 'https://conda.anaconda.org/conda-forge/linux-64/repodata.jlap': Request failed after 3 retries. Assuming its unavailable..
 WARN rattler_repodata_gateway::fetch: failed to perform HEAD request on 'https://conda.anaconda.org/conda-forge/noarch/repodata.json.zst': Request failed after 3 retries. Assuming its unavailable..
 WARN reqwest_retry::middleware: Retry attempt #0. Sleeping 107.855292ms before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #0. Sleeping 743.714953ms before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #1. Sleeping 1.341636683s before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #1. Sleeping 55.567696ms before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #2. Sleeping 2.429520142s before the next attempt
 WARN reqwest_retry::middleware: Retry attempt #2. Sleeping 1.869665217s before the next attempt
Error:
  x Couldn't install shellcheck
  |-> Request failed after 3 retries
  |-> error sending request for url (https://conda.anaconda.org/conda-forge/linux-64/repodata.json)
  |-> client error (Connect)
  |-> dns error: failed to lookup address information: Try again
  `-> failed to lookup address information: Try again

This is with the following Dockerfile (per your request):

FROM ubuntu:latest
RUN apt-get update --yes \
 && apt-get install --yes --no-install-recommends \
    curl \
    ca-certificates \
    openssl \
 && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://pixi.sh/install.sh | bash

Thanks for looking at this!

ctcjab avatar Feb 25 '25 22:02 ctcjab

Just to report observing the same issue once (pixi complaining about address lookup, while other utilities work well in the container). The environment is podman in Ubuntu 24.04, using ghcr.io/prefix-dev/pixi:0.59.0 base image. The issue persisted with different base container versions and apt packages installed before calling pixi, but has gone after reboot.

dsavchenko avatar Nov 19 '25 14:11 dsavchenko

I think this has mostly been solved with recent versions where we bumped the targeted musl version. Feel free to reopen if this still occurs.

baszalmstra avatar May 28 '26 08:05 baszalmstra