Git commands no longer working in your docker container? Read on to find out why.

Have you ever setup your Docker container just the way you want it? Perhaps you set your git config files just the way you wanted them only to have your git configuration file completely bastardised once you connected your container to Visual Studio.

The first inkling of trouble ahead may have been sparked by the sudden error “Remote-Containers CLI: RPC pipe not configured” when trying any git command that previously worked alright in your container. None of them work, git checkout, git commit, or git push.

Remote-Containers CLI: RPC pipe not configured

You might have got as far as checking your credentials file and if the following image looks familiar then you know exactly what I am talking about.

Bastardised .gitconfig

You can thank Visual Studio Code for this trouble.

I don’t know why Visual Studio Code as default decides to copy your local machine git credentials to a docker container. Is it really wise to have your email address, and docker account details uploaded to a container you are sharing with your team or the public? Even worse, look at that default core editor referenced in .gitconfig – that may not even be a valid editor for the container you are working on.

Solution

Step 1: Open Visual Studio Code

Make sure Visual Studio Code isn’t already running, if it is disconnect from all target containers and target ssh connections. Reopen Visual Studio Code. This is the only way I can seem to get to the appropriate settings.

Step 2: Open Settings

Select File>Preferences>Settings

Step 3: Modify Settings In User Settings

Make sure you have selected the ‘User’ tab. It should be the only tab available if you have freshly opened Visual Studio Code.

In the User settings search box type ‘remote.container’.
The first setting you want to make sure is unchecked is,

“Remote > Containers: Copy Git Config”.

Next, scroll down until you see the next setting,

“Remote > Containers: Git Credential Helper Config Location”

Make sure that you set the value to “none” in the dropdown menu.

That’s it! When you next connect to a container your git credentials won’t be messed with.

Visual Studio Code Setting Sync Issue

Visual Studio Code is capable of synchronizing your settings when you login across other machines.

Unfortunately the bad news is that these modified git/container settings cannot be set to sync across all your machines when you login to Visual Studio Code. Oh well – you will just have to go through the above again on each development machine you have.

Leave a Reply