I am creating a nodejs application that will integrate with Git repo and perform operations such as push, pull commit etc. I am in the process of moving the app to Docker. However I can't find a way to put ssh keys in the docker image at runtime. I want to avoid copying the ssh key at build time in the docker image for security reasons.
I have tried passing the ssh key as an env variable at runtime like :
docker run -i -t -e KEY="sshkey" imagename
And in node.js manually creating the ssh folder and ssh key
mkdirSync('/root/.ssh/', (err) => {
writeFileSync('/root/.ssh/id_rsa.pub', sshKey, (err) => {
})
})
However this doesn't seem to be working, I still get permission errors when trying to clone the repo.
- Do I need to do something to load the ssh keys so they can be used by git?
- Is there a way to do it using Dockerfile. I know that I can add it on build, time, but haven't found a way to do it at runtime.
- How can I inspect the fs of a running docker container?