Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't clone public repo from within Dockerfile

Tags:

github

docker

I have the following line in my Dockerfile:

RUN git clone https://github.com/assafg/youtube-remote.git ./youtube-remote

When executing sudo docker build -t 'yremote' . I get the following error:

Cloning into './youtube-remote'... fatal: unable to access 'https://github.com/assafg/youtube-remote.git/': Could not resolve host: github.com The command '/bin/sh -c git clone https://github.com/assafg/youtube-remote.git ./youtube-remote' returned a non-zero code: 128

Running clone command from command line works fine.

like image 463
Overflown Avatar asked Dec 29 '15 14:12

Overflown


People also ask

Can you clone a public repository?

You can create a complete local copy of a Git repository from a public project by cloning it. Cloning a repo downloads all commits and branches in the repo and sets up a named relationship with the existing repo you cloned.

Can private repos be cloned?

Yes! We can do that following these steps: Create a new Blank Project instead of Clone. Click the 'Configure Git' button and use the existing private repo for the git remote.


1 Answers

This can happen if your container can't connect to the internet. Possibly because it was started with a weird networking option? Run this command to check default internet connectivity:

docker run ubuntu apt install -y git && \
git clone https://github.com/assafg/youtube-remote.git ./youtube-remote

If that container successfully pulls down the repo, it probably means the first container has a networking problem. Try to restart, or change networking settings.

Docker Network just became a first class citizen in the Docker ecosystem. It's a really fast-moving project. This advice applies to v1.8

like image 182
code_monk Avatar answered Sep 20 '22 22:09

code_monk