Docker Community Forums

Share and learn in the Docker community.

Docker build fails on 'pip install' from "Temporary failure in name resolution"

I’m experiencing a problem when I try to build a docker image that runs the following command:

pip install -r /app/requirements

It repeats the following warning 5 times and then finishes with a couple error messages:

WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f16136c2b50>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/ariadne/ 
ERROR: Could not find a version that satisfies the requirement ariadne (from -r /app/requirements.txt (line 1)) (from versions: none)
ERROR: No matching distribution found for ariadne (from -r /app/requirements.txt (line 1))
The command '/bin/sh -c pip install -r /app/requirements.txt' returned a non-zero code: 1

The build command I am using is simply:

docker build -t service_name .

However, if I create a new bridge network and use that during the build, then it works:

docker build -t service_name --network=my-network .

This makes me think the problem is with the default bridge network. (If docker-compose provided a way to specify the network used during build then I may be able to avoid this problem, but I couldn’t see how to do that.)

This is off of a fresh uninstall, install & update of Docker Desktop. Here are hopefully all of the relevant version numbers:

  • Docker Desktop 2.1.0.5 (40693)
  • Engine: 19.03.5
  • Compose: 1.24.1
  • Machine: 0.16.2
  • Windows 10 Pro for Workstations

Dockerfile:

FROM tiangolo/uvicorn-gunicorn:python3.7
COPY ./app /app
RUN pip install -r /app/requirements.txt
EXPOSE 80

docker network inspect for my default bridge:

[
{
    "Name": "bridge",
    "Id": "ac9418446e5e221df6fc3cee7ee14d2ab2871c50f42020abb3173df06e3409bf",
    "Created": "2020-01-15T17:39:31.7790633Z",
    "Scope": "local",
    "Driver": "bridge",
    "EnableIPv6": false,
    "IPAM": {
        "Driver": "default",
        "Options": null,
        "Config": [
            {
                "Subnet": "172.17.0.0/16",
                "Gateway": "172.17.0.1"
            }
        ]
    },
    "Internal": false,
    "Attachable": false,
    "Ingress": false,
    "ConfigFrom": {
        "Network": ""
    },
    "ConfigOnly": false,
    "Containers": {},
    "Options": {
        "com.docker.network.bridge.default_bridge": "true",
        "com.docker.network.bridge.enable_icc": "true",
        "com.docker.network.bridge.enable_ip_masquerade": "true",
        "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
        "com.docker.network.bridge.name": "docker0",
        "com.docker.network.driver.mtu": "1500"
    },
    "Labels": {}
}]

docker network inspect for my-network:

[
{
    "Name": "my-network",
    "Id": "a3aa1289a7cf12b4eccb2d44f027dcf1a18d9d2fffdf88a52372a2c1cbe9c263",
    "Created": "2020-01-15T18:49:03.4952734Z",
    "Scope": "local",
    "Driver": "bridge",
    "EnableIPv6": false,
    "IPAM": {
        "Driver": "default",
        "Options": {},
        "Config": [
            {
                "Subnet": "172.19.0.0/16",
                "Gateway": "172.19.0.1"
            }
        ]
    },
    "Internal": false,
    "Attachable": false,
    "Ingress": false,
    "ConfigFrom": {
        "Network": ""
    },
    "ConfigOnly": false,
    "Containers": {},
    "Options": {},
    "Labels": {}
}]

thanks

Since I just replied to a similar question, i’ll just link my other reply.