Thumbnail image

VScode Devcontainer and Git Signing

Table of Contents


I have long been a fan of VScode DevContainer extention.

The idea is really simple. To make sure you have a clean, reusable dev enviroment, for each of your projects, you spin it up in a container, with all the dependencies you need.

Simple right ?


Setting up a new laptop, I descided that I needed to be better at creating enviroments, that I can reuse across different systems etc. So I started setting up a simple Devcontainer env.

But starting on a new laptop, also ment, that I just setup Git signing, using SSH keys. And at the very first commit, I encountered the problem.

Signing did now work.


It’s kinda simple. The VScode env takes all my settings, and put’s them into the container. The path and the SSH key is just not there, and there is no mapning to the key files.


The solution was also kinda simple. Map the .ssh directory into my Container.

So my new Devcontainer.json file looks like this

	"name": "Python 3",
	"image": "",

	"mounts": [

To make sure it’s reusable across different accounts, I used the ${localEnv:HOME} path, instead of a hardcoded path.

Now all my commits are verified again (as they should be), and it’s reusable everywhere I need it. Just note, that I need to have a SSH key, that I can use to sign, on any system I run this on. verified

If you are not signing your commit, then you should get started ASAP. It’s not that hard, and since Git 2.34 it’s been possible to use a SSH key as signing which for me, makes it a lot easier.

Github has a nice Guide on how to set this up.

Photo by Lewis Keegan on Unsplash

Related Posts