I'm trying to clone a project from gitlab in a docker but having authentication failure issue. Outside of docker, it works well to checkout the project using git clone command.
$ git clone "git repo url"
I started docker image using the command as follow.
$ docker run -it -u $(id -u):$(id -g) -v /home/user1:/home/user1 build:001 /bin/bash
I see $(id -u) and $(id -g) displays the same user id and group id between inside of docker and outside of docker. But if I run the command git clone "git repo url" inside, I see the error as follow.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gitlab.com' (ED25519) to the list of known hosts.
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
ubuntu@c94de1e3de20:$
And this is the list of ls -la /home/user/.ssh in the docker.
ubuntu@bfe53a9a6d12:/home/user1$ cd .ssh/
ubuntu@bfe53a9a6d12:/home/user1/.ssh$ ls -la
total 24
drwx------ 2 ubuntu ubuntu 4096 Aug 19 18:25 .
drwxr-x--- 24 ubuntu ubuntu 4096 Aug 20 18:24 ..
-rw------- 1 ubuntu ubuntu 0 May 9 16:12 authorized_keys
-rw------- 1 ubuntu ubuntu 399 Jul 3 18:28 id_ed25519
-rw-r--r-- 1 ubuntu ubuntu 93 Jul 3 18:28 id_ed25519.pub
-rw------- 1 ubuntu ubuntu 1120 Jul 15 20:16 known_hosts
-rw-r--r-- 1 ubuntu ubuntu 284 Jul 15 20:16 known_hosts.old
ubuntu@bfe53a9a6d12:/home/user1/.ssh$
I am searching on the web, not didn't have any good luck yet. It would be great if someone can find what I did incorrectly.
/home/user1and the home directory of the ubuntu user within the container the same path? 2) Can you post the output ofls -l /home/user1/.ssh/from within the container?/home/ubuntu/.ssh, but the keys are actually at/home/user1/.ssh. The permissions look fine though.-v /home/user1:/home/user1, this is mounting the first part before the:into the container at the path in the second part. So you can present the files under a different path inside the container by doing-v /home/user1:/home/ubuntu. "Also, I registered the public key to gitlab server. If I use ubuntu user inside docker instead of using user1, will it be working without another problem?" No, that isn't a problem.