I am trying to add a private key in my Docker container which has access to my private git repositories. The testing_git file is in the folder containing Dockerfile. I am tr
The error message Host key verification failed.
is not complaining about your private key, but rather the host key for github.com. You can do this to add the github hostkey:
ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts
Perhaps you have your reasons, but in general cloning the git repo in to the image is not the preferred way to run your code in a container. Instead, put a Dockerfile at the root of your repo, and within the Dockerfile use the ADD
command to include your source code in the container.
As you have it written now, your private key is part of the Docker image. Anyone you share the image with will also have your private key.