How to access GIT repo with my private key from Dockerfile

前端 未结 1 892
感动是毒
感动是毒 2020-12-24 05:56

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

相关标签:
1条回答
  • 2020-12-24 06:29

    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.

    0 讨论(0)
提交回复
热议问题