Reputation: 67
I need to create a Docker image that will clone a Github repo (send as parameter) and will perform some operations with it. For public repos I have no problems, but with private repos, how can I clone them inside my Docker container?
Upvotes: 1
Views: 99
Reputation: 2469
We have done the following:
Then, in our Docker image that needs to read the repo, we have the following:
COPY github.pub /root/.ssh/id_rsa.pub
RUN chmod 700 /root/.ssh/id_rsa.pub
COPY github /root/.ssh/id_rsa
RUN chmod 700 /root/.ssh/id_rsa
RUN chown -R root:root /root/.ssh
RUN touch /root/.ssh/known_hosts
RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
Where guthub.pub
and github
are the files of your SSH key.
With this mechanism, you just need to ask them to add you GitHub account as reader of the repo, and you don't need to ask people for private keys or more complex setup, which is very convenient.
Upvotes: 3