0

I was creating my own development env with docker this is my docker file

FROM alpine:latest
WORKDIR /app
RUN apk update
RUN apk upgrade
RUN reboot
RUN apk add --no-cache make
RUN apk add 
RUN git config --global user.name "username"
RUN git config --global user.email "email"
RUN git config --global init.defaultBranch main
RUN export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
RUN reboot

and one more thing in my original file I have given proper username and email for the git config

now I created image out of this Dockerfile with

docker build -t xyz .

created a container using

docker run --rm -it -v %cd%:/app xyz sh

but the problem comes when I try to clone a directory

git clone https://github.com/coder/code-server.git

the error I get

Cloning into 'code-server'...
fatal: unable to access 'https://github.com/coder/code-server.git/': Could not resolve host: github.com

is this problem from the docker networking part (do I have to define DNS manually ..?) enter image description here and my internet is working perfectly and I can ping google.com but not github.com enter image description here

the things I have tried to solve this problem

git config --global --unset https.proxy (used this) (didn't work) git config --global --unset http.proxy (used this) (didn't work) tried to use ssh still didn't work (using openssh-client) (i installed openssh-client on the alpine) and I more thing I have tried to clone the repo on other folders also (other than the mounted folder /app)

I was expecting that the container can reach the github.com

  • Does this answer your question? [Network calls fail during image build on corporate network](https://stackoverflow.com/questions/24151129/network-calls-fail-during-image-build-on-corporate-network) – β.εηοιτ.βε Jun 26 '23 at 16:58

1 Answers1

0

Pretty sure this is a DNS issue, so try, as mentionned in this answer, to run your docker image with a dns ip configured :

docker run --rm -it --dns 10.0.0.2 -v %cd%:/app xyz sh

Be careful to add --dns 10.0.0.2

Replace "10.0.0.2" by your DNS IP (ipconfig --all or ipconfig /a)

bschaffh
  • 114
  • 8
  • 1
    You might flag this question as a duplicate of [Inside docker got error as fatal: unable to access Could not resolve host: github.com](https://stackoverflow.com/questions/62376346/inside-docker-got-error-as-fatal-unable-to-access-url-could-not-resolve-host) rather than repeating its answer. That in turn cites [Network calls fail during image build on corporate network](https://stackoverflow.com/questions/24151129/network-calls-fail-during-image-build-on-corporate-network) and possibly that is an even better duplicate target. – David Maze Jun 26 '23 at 15:00
  • Yes i haven't thought about doing so, I will be more carefull in the future, my bad ! – bschaffh Jun 26 '23 at 15:03
  • yea it's now working like a charm thank you @bschaffh . one more thing I think the best dns to use 8.8.8.8 or 0.0.0.0 instead of your computers dns ip thank you again – AYUSH Mondal Jun 26 '23 at 16:21