Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

building Docker from private repo #223

Open
osrf-migration opened this issue Jun 6, 2017 · 6 comments
Open

building Docker from private repo #223

osrf-migration opened this issue Jun 6, 2017 · 6 comments
Labels
bug Something isn't working cloud major

Comments

@osrf-migration
Copy link

Original report (archived issue) by Tyler Frasca (Bitbucket: tmfrasca5).


Hi, locally I can clone my private repository and then build it with:

eval "$(ssh-agent -s)"
ssh-add <private key path>
ssh-keyscan github.com >> ~/.ssh/known_hosts
git clone git@github.com:<user>/<repo>.git
cd <repo>
sudo docker build -t field_comp .

But, I am having issues locally building the docker directly from the private repo.

eval "$(ssh-agent -s)"
ssh-add <private key path>
ssh-keyscan github.com >> ~/.ssh/known_hosts

sudo docker build -t fc git@github.com:<user>/<repo>.git


I get this error:

unable to prepare context: unable to 'git clone' to temporary context directory: Error trying to use git: exit status 128 (Cloning into '/tmp/docker-build-git358219479'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
)

Thus I am not able build my docker on the cloud.
Any help would be greatly appreciated.

@osrf-migration
Copy link
Author

Original comment by GoRobotGo (Bitbucket: GoRobotGo).


There are a number of ways it might work. Using your approach you need to put the private key in your repository and use an ADD command to move the key from your repository to the docker image.

Another approach is since your private repository is already mounted when you are building the docker image, you can use ADD commands in your Dockerfile to move items from your github repository to the docker image.

Yet another approach is to use something like: RUN git clone https://username:password@github.com/username/repository.git ${WS}/src/repository

@osrf-migration
Copy link
Author

Original comment by Tyler Frasca (Bitbucket: tmfrasca5).


So even for cloning the top github repo which contains the Docker file, I need to add the private key to that top level repo??

@osrf-migration
Copy link
Author

Original comment by GoRobotGo (Bitbucket: GoRobotGo).


You give a key to cloudsim.io. That allows it access to the github repo and it gets the docker file from there. So, no - you don't need to add the private key to the repo to get that. You only need to add the private key if you want to be able to run a git clone command within your docker file. In the example you can also see it uses ADD to move the footstep file from the repository to the docker image.

@osrf-migration
Copy link
Author

Original comment by Tyler Frasca (Bitbucket: tmfrasca5).


Yeah, that is what I have been doing, but I get:

unable to prepare context: unable to 'git clone' to temporary context directory: Error trying to use git: exit status 128 (Cloning into '/tmp/docker-build-git358219479'... 
Permission denied (publickey). 
fatal: Could not read from remote repository.  
Please make sure you have the correct access rights and the repository exists. )

when entering the key to cloudsim should it be line separating (like the way it is in the file) or all on a single line?

@osrf-migration
Copy link
Author

Original comment by GoRobotGo (Bitbucket: GoRobotGo).


When I enter the key in cloudsim I do this in a window: more ~/.ssh/id_rsa

and then I copy everything - that includes the begin key and end key line. I then paste that into cloudsim.

@osrf-migration
Copy link
Author

Original comment by Tyler Frasca (Bitbucket: tmfrasca5).


Thanks, the issue was that I wasn't copying the full key -> including the begin and end lines

@osrf-migration osrf-migration added major cloud bug Something isn't working labels May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cloud major
Projects
None yet
Development

No branches or pull requests

1 participant