'How to install vscode extension in dockerfile?

Adding extensions into .devcontainer will make vscode install them every time I reopen the folder in container, which can not take advantage from docker layer cache to accelerate the starting even if extension settings are not changed. Is there a way to install these extensions in Dockerfile?



Solution 1:[1]

Per the VS Code Documentation, the extensions property is specific to VS Code and can only be configured using .devcontainer.

The best you can do is if the extension has a CLI, you can install that. For example,

RUN npm install prettier -D --save-exact

Then use npx:

npx prettier --check .

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1