Docker-alpine: Can't clone private git repo

Created on 16 Jul 2015  路  2Comments  路  Source: gliderlabs/docker-alpine

Is there a preferred way to clone a private git repo? All my attempts to get this to work so far are failing.

I am copying a private key in to my container and attempting to use it to clone a private repo. I can clone the repo manually if I log in to the container and accept the RSA fingerprint.

This is always failing when I attempt to automate the pulling of the private repo, I have tried tried adding to disable strict host key checking by adding a config in /root/.ssh/config. I have tried other various configs in the ssh_config but haven't had any luck.

Here is the message I am seeing.

Step 7 : RUN git clone [email protected]:mycoolrepo.git /opt/repo
 ---> Running in de83ebb98ee9
Cloning into '/opt/repo'...
Host key verification failed.
fatal: Could not read from remote repository.

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

The line in the Dockerfile looks like this:

COPY id_rsa /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa && echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config

This method is working for other distros. How can I get the key to automatically get accepted?

As a note, I am able to copy an existing known_hosts file in to the image and it works.

Most helpful comment

Got it. I had to add the following to the Dockerfile.

RUN ssh-keyscan github.com >> ~/.ssh/known_hosts

All 2 comments

Got it. I had to add the following to the Dockerfile.

RUN ssh-keyscan github.com >> ~/.ssh/known_hosts

Can you share complete DockerFile?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

u6f6o picture u6f6o  路  4Comments

gliptak picture gliptak  路  4Comments

kooksee picture kooksee  路  4Comments

konradjurk picture konradjurk  路  5Comments

javixeneize picture javixeneize  路  4Comments