Docker Community Forums

Share and learn in the Docker community.

How to do git pull from a private repo when docker build

(Lvhuat) #1

What if we want go pull code from a private repo and build this code at go build time .
To goal this,i have do some tries.
1.Do RUN ADD /root/.ssh/id_rsa /root/.ssh/id_rsa
2.Use shell script in Docker file,the script is:

eval “$(ssh-agent)” && ssh-agent -s
chmod 0600 /root/.ssh/id_rsa
ssh-add /root/.ssh/id_rsa
git clone git@ -b new

then, RUN
id_rsa` was add into agent,but it still do not work

By the way,i have aready read this issue
It seem that there have’t any way to do pull from a private repo successfully when docker build
Must i compile my code at docker run time?