Home > Article > Backend Development > How to Retrieve Code from a Private GitHub Repository in Docker?
Docker: Retrieving Code from a Private GitHub Repository
Encountering difficulties while retrieving code from a private GitHub repository during Docker container execution? This problem manifests with an error indicating a failure to read the username for 'https://github.com'.
To address this issue, it's necessary to augment the Dockerfile with a series of steps:
Here's a modified Dockerfile that incorporates these steps:
FROM golang RUN apt-get update && apt-get install -y ca-certificates git-core ssh ADD keys/my_key_rsa /root/.ssh/id_rsa RUN chmod 700 /root/.ssh/id_rsa RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config RUN git config --global url.ssh://[email protected]/.insteadOf https://github.com/ ADD . /go/src/github.com/myaccount/myprivaterepo RUN go get github.com/myaccount/myprivaterepo RUN go install github.com/myaccount/myprivaterepo
With this modified Dockerfile, you can now retrieve code from a private GitHub repository during container execution.
The above is the detailed content of How to Retrieve Code from a Private GitHub Repository in Docker?. For more information, please follow other related articles on the PHP Chinese website!