I am not sure I understand the question.
These cache mounts are used when building images (eg: they mount the cached folder during a RUN
command in a dockerfile). So you could use it when building an new image for a dev container.
If you are thinking about caching the build artifacts for a package you open in a dev container, these do not apply.
However, as long as you are using the same container, your .build
folder should stay there without any additional tricks. I guess if you wanted to keep the .build
folder on the host machine (surviving between different containers) you could use "normal" bind mounts when spinning up the dev container - not sure how to configure this in vscode though.
edit: actually, I think vscode mounts your project's folder anyway, so you should the build cache in your local file system just as normal.