Mekal Z

Mekal Z

A programmer running out of the wall.

Recording a Docker Build DNS resolution issue

When I executed the following command to build a Docker image in my local Ubuntu system, I encountered a DNS resolution issue. I used GoProxy to specify the Alibaba Cloud proxy in the Dockerfile, but the DNS resolution failed during the build process.

sudo docker compose -f ./compose-dev.yaml build

[+] Building 2.0s (9/14)
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                                                                                                                        0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                                                                   0.0s
 => => transferring dockerfile: 1.27kB                                                                                                                                                                                                                                                                                                                                 0.0s
 => [internal] load metadata for                                                                                                                                                                                                                                                                                                  1.5s
 => [builder 1/7] FROM                                                                                                                                                                                                                                    0.0s
 => [internal] load build context                                                                                                                                                                                                                                                                                                                                      0.0s
 => => transferring context: 812.84kB                                                                                                                                                                                                                                                                                                                                  0.0s
 => CACHED [builder 2/7] RUN mkdir -p /app                                                                                                                                                                                                                                                                                                                             0.0s
 => CACHED [builder 3/7] WORKDIR /app                                                                                                                                                                                                                                                                                                                                  0.0s
 => [builder 4/7] COPY . /app                                                                                                                                                                                                                                                                                                                                          0.0s
 => ERROR [builder 5/7] RUN go env -w GOPROXY=,direct     && go get -d -v ./...                                                                                                                                                                                                                                                     0.3s
 > [builder 5/7] RUN go env -w GOPROXY=,direct     && go get -d -v ./...:
#0 0.313 go: Get "": dial tcp: lookup on [240e:d:0:100::6]:53: dial udp [240e:d:0:100::6]:53: connect: cannot assign requested address
failed to solve: process "/bin/sh -c go env -w GOPROXY=,direct     && go get -d -v ./..." did not complete successfully: exit code: 1

The solution is to set the DNS in /etc/docker/daemon.json, for example:

    "dns": ["", ""],
    "log-driver": "json-file",
    "log-opts": {
        "max-size": "50m",
        "max-file": "3"
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.