I'm trying to get a docker image to build that requires it to clone a private github repo.
Asked
Active
Viewed 330 times
0
-
Here - http://stackoverflow.com/a/24937401/2689986 – shad0w_wa1k3r Mar 29 '17 at 06:37
-
1Possible duplicate of [Using SSH keys inside docker container](http://stackoverflow.com/questions/18136389/using-ssh-keys-inside-docker-container) – shad0w_wa1k3r Mar 29 '17 at 06:38
1 Answers
1
I had a hard time figuring out how to do this without copying my ssh keys over - my eventual solution was to use a github basic auth token in URL format passed into docker as a build argument.
In Dockerfile
ARG GITHUB_URL RUN git config --global url.$GITHUB_URL.insteadOf "https://github.com/"
RUN go get -u github.com/YOUR_USERNAME/YOUR_REPO
When Building
docker build -t YOUR_TAG . --build-arg GITHUB_URL="https://[YOUR_GITHUB_TOKEN]:x-oauth-basic@github.com/"

Logan Shire
- 5,013
- 4
- 29
- 37