1

this question is identical to Is there a way to get git to work properly from within a dev container using VS Code? but unfortunately, that post was marked as solved due to a fix in Docker. I have a more current version of Docker and VS Code as reported with the fix and am having this issue, which leads me to think that it's something else.

The problem: I'm prompted that I don't have git installed and my understanding is that I don't have to install a separate git within the image but can use the one on my host machine. Unfortunately, vs code is unable to detect it. My workaround is to disconnect from the dev container and then run my git operations but I'd rather not go through that.

My version of Docker is Docker version 20.10.1, build 831ebeae96 and VS Code is 1.52.1 on Linux.

My dockerfile is:

FROM ubuntu:latest

RUN apt-get -y update && apt-get install -y

RUN apt-get -y install clang

COPY . /usr/src

WORKDIR /usr/src

and my devcontainer.json is

{
    "name": "Existing Dockerfile",
    "dockerFile": "../Dockerfile",
    "settings": {
        "terminal.integrated.shell.linux": null,
        "git.path": "/usr/bin/git",  // added by me, tried without this line as well
    },
}
reactor
  • 1,722
  • 1
  • 14
  • 34
  • 1
    If something in your application or build system is calling `git`, then it needs to be installed in the container. Container applications can never run binaries that only live in the host (and can't generally access the host's filesystem at all). – David Maze Dec 24 '20 at 22:53
  • @DavidMaze thanks. I was afraid of that, since I'd like to keep the size of my images as lean as possible. – reactor Dec 25 '20 at 05:32

0 Answers0