The following paragraph in the official docs describes how to enable GPG key sharing (from localhost to Remote Container) in VSCode (https://code.visualstudio.com/docs/remote/containers#_sharing-gpg-keys).
The instructions (for Linux) simply state that to share GPG keys, install gnupg2
locally and in the container. But what if I have gnupg2
installed but I don’t want to have the keys shared? From what I can tell, VSCode execs post-startup commands within the container where the key sharing gets done, e.g.:
Copy /home/karlschriek/.gnupg/pubring.kbx to /home/vscode/.gnupg/pubring.kbx
Copy /home/karlschriek/.gnupg/trustdb.gpg to /home/vscode/.gnupg/trustdb.gpg
...
I have not been able to find a setting that will prevent this. It is also, presumably, using the same gpg-agent
as the localhost. I would like to prevent this.
2
Answers
Since this behavior does not seem configurable, I would
GNUPGHOME
environment variableexport GNUPGHOME=""
That way, VSCode would search for gnupg files to share in the default ~/.gnupg folder, which is not used in your case.
It is a simple workaround, not an exact solution, but one simple enough to test.
Just to add another detail which might help someone: notice that you have to install gnupg locally and in the container. I was running into issues with a gnupg command failing during startup and was able to solve it by removing gnupg in my dockerfile (it had been installed automatically).