Search code examples
dockervisual-studio-codedockerfiledocker-machine

Getting Docker Dev Engine to work with VS Code


whenever I run the dev engine, I get the following error at the end of the install:

chown: invalid group: ‘root:docker’
WARNING: Could not change owner for docker socket in container : exit code 1
Docker socket permission set to allow in container docker

I am on macOS, so not sure if I need to create a docker group or not.

I have the following Dockerfile.devenv

FROM python:3.9-buster
COPY requirements.txt requirements.txt
COPY . .
RUN pip install -r requirements.txt
USER root
WORKDIR /src
EXPOSE 8000
RUN useradd -ms /bin/bash devenv

and no docker compose file.


Solution

  • Based on docker documentation when we are specifying Dockerfile, we need to make sure that we are using vscode user and included to docker group.

    So i think your Dockerfile.devenv need to be updated. e.g:

    FROM python:3.9-buster
    
    WORKDIR /src
    COPY requirements.txt requirements.txt
    COPY . .
    RUN pip install -r requirements.txt
    
    # create vscode user then add to docker group
    RUN useradd -s /bin/bash -m vscode \
     && groupadd docker \
     && usermod -aG docker vscode
    
    USER vscode
    
    EXPOSE 8000