How to install vscode extension in dockerfile?

Viewed 473

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?

1 Answers

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 .
Related