0

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!

R1ky68
  • 40
  • 1
  • 8
  • Can you address that URL from a browser? seems to be an internet/DNS problem that is not related to Docker. – Giorgi Tsiklauri Jul 14 '23 at 08:35
  • I'm sorry, it was a stupid answer and I deleted the comment. Yes I can address the URL from a browser correctly. – R1ky68 Jul 14 '23 at 08:49
  • I don't know what your previous comment was, but it's weird, if you can access URL from the browser and not from Docker.. is your Docker using same network configuration (proxy, firewall, etc.) that your browser does? – Giorgi Tsiklauri Jul 14 '23 at 08:56
  • I searched a bit and in my `~/.docker/config.json` there is no proxy configuration. Then, I inspected the network of the container i'm trying to run using `docker network inspect ` and [this](https://pastebin.com/5PnvEJwZ) was the result. I finally inspected all the networks on my machine using `ifconfig -a` getting [this](https://pastebin.com/6Wk47UhW) result. Hope this helps. – R1ky68 Jul 14 '23 at 09:34

0 Answers0