Emobe
Emobe

Reputation: 712

Curl could not resolve host using Docker on WSL 2

I am trying to use curl to download releases from github and it cannot seem to resolve the domain.

I get the error curl: (6) Could not resolve host: objects.githubusercontent.com

I am running Docker on WSL 2. Part of my Dockerfile is below and it doesn't get past the curl command

FROM alpine:latest
WORKDIR /app
RUN apk update && apk add curl unzip 
RUN curl -LO https://github.com/oven-sh/bun/releases/download/bun-v0.1.3/bun-linux-x64.zip && unzip bun-linux-x64.zip
COPY ["package.json", "bun.lockb", "./"]
RUN echo ls
RUN /usr/local/bin/bun-linux-x64/bun install

Any help is appreciated

Upvotes: 5

Views: 19767

Answers (3)

maccevedor
maccevedor

Reputation: 165

It's a silly thing to do, but check that you're not connected to a VPN or that it's not your internet service.

Upvotes: 2

Fahad Munir
Fahad Munir

Reputation: 482

In case you don't use the Docker Desktop app and have installed Docker in the WSL2 Ubuntu instance, edit/create a config file: /etc/docker/daemon.json and set default DNS:

{
  "dns": ["8.8.8.8"]
}

Restart the Docker service:

service docker restart

Upvotes: 12

SeanTech
SeanTech

Reputation: 43

Try configuring the docker daemon to use a default dns server by configuring daemon.json.

If using Docker Desktop, you should NOT edit the file directly. It can be edited from within Docker Desktop, under Preferences / Daemon / Advanced.

Else the file can be found (or created) at C:\ProgramData\Docker\config\daemon.json.

Configuring the Google dns server 8.8.8.8 in an empty file would look something like this:

{
    "dns": 
    [
        "8.8.8.8"
    ]
}

More information about daemon.json can be found here.

Upvotes: 4

Related Questions