0

To be clear: I'm talking about the Docker-Desktop feature "Dev Environments". See here.

I think I'm missing something about the build process of Docker DevEnv. When I build my DevEnv I can see in the logs that npm install is running and necessary files get created. I can even see them when inspecting the container files. But when opening the DevEnv in VS Code a new container gets created overriding the old one and thus deleting all files created in the build process.

Detailed explanation

I want to run Node.js in a Docker DevEnv and work inside it with VS Code. I have a really simple setup with a compose-dev.yaml file that looks like this:

version: '3'
services:
  app:
    platform: linux/arm64
    build:
      context: .
      target: runner
    entrypoint:
      - sleep
      - infinity
    ports:
      - 1234:1234

And a Dockerfile that looks like this:

# development builder (faster than runner, do heavy tasks in here!)
FROM node:20 AS development

WORKDIR "/com.docker.devenvironments.code"

COPY . .

RUN npm install



# development runner (ARM/M1 compatible)
FROM --platform=linux/amd64 node:20 AS runner

COPY --from=development . .

The 2 stage build process is because I work on an M1 chip. I think this is not related to my problem.

When I setup the DevEnv in Docker-Desktop I can see in the logs that npm install is running as declared in the Dockerfile. npm install running in build

When inspecting the new container I can see the newly generated node_modules/ folder. generated files are present

But when clicking "Open in VSCode" Docker seems to create a new container overriding the old one. new container started

The new container kinda overrides the old one and all the generated files are now lost. node_modules/ missing

So I don't think this is a bug but im getting sth wrong here. I don't know why I should specify anything in the Dockerfile if it's getting deleted anyways. When opening "normal" Docker containers in VSCode this doesn't happen.

I would expect that opening the DevEnv in VSCode is not overriding every change made in the build process of my DevEnv.

Bruno
  • 1

0 Answers0