Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save smichaelsen/f9f65ae3dbbdad911861ec5ec1b32002 to your computer and use it in GitHub Desktop.
Save smichaelsen/f9f65ae3dbbdad911861ec5ec1b32002 to your computer and use it in GitHub Desktop.
Use SSH key from host machine in docker CI server

We run a CI server for some of our gitlab.com hosted projects. For that we have a machine over at digitalocean.com, for which I followed this tutorial: https://about.gitlab.com/2016/04/19/how-to-set-up-gitlab-runner-on-digitalocean/

Now we have the problem that our repositories have git dependencies which are not public but have to be cloned via SSH authentication. As a quick-fix we're shipping SSH keys in our repositories which grant access to those dependencies, but that doesn't seem like a good idea.

I think it would be good to have a SSH key centrally on the CI server. Unfortunatelly we're everything but docker pros and have no idea how to access a SSH key on the host machine from within the docker image. Maybe you can mount a folder via the Dockerfile, but the above tutorial doesn't include creating one, so I'm not sure where I should do that.

Any help is appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment