I'm trying to build a Docker image using the official golang:1.19-alpine image and adding git in order to pull a private project.
Dockerfile
FROM golang:1.19-alpine
RUN apk update
RUN apk add --no-cache git
ENV GOPRIVATE=bitbucket.org/<organization_name>
RUN echo "machine bitbucket.org login <username> password <password>" > $HOME/.netrc
WORKDIR /app
COPY go.mod ./
COPY go.sum ./
RUN go install github.com/githubnemo/CompileDaemon@latest
RUN go mod download
COPY . .
EXPOSE 8004
ENTRYPOINT CompileDaemon --build="go build main.go" --command=./main
The result is getting an error at apk command, with the following output:
> [ 2/10] RUN apk update:
#0 0.297 fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/main/x86_64/APKINDEX.tar.gz
#0 0.314 WARNING: updating and opening https://dl-cdn.alpinelinux.org/alpine/v3.18/main: DNS lookup error
#0 0.314 fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/community/x86_64/APKINDEX.tar.gz
#0 0.328 4 unavailable, 0 stale; 16 distinct packages available
#0 0.328 WARNING: updating and opening https://dl-cdn.alpinelinux.org/alpine/v3.18/community: DNS lookup error
------
failed to solve: executor failed running [/bin/sh -c apk update]: exit code: 4
I've tried to solve the problem with this answer but I think it's a problem with the URLs the machine is trying to fetch.
OS: Ubuntu 22.04 Any suggestion will be really appreciated, thanks in advance!