Automatic installation of an extension in VSCode from a *.vsix file when starting a Dev Container

After a few attempts, I finally found a working solution for this problem.

The situation: I am developing my own VSCode extension and using a Docker container as my development environment. In order to test the extension continuously, I want it to be installed automatically whenever the Dev Container starts.

Normally, extensions are listed in devcontainer.json under "customizations": { "vscode": { "extensions": [] }}. However, this only works for extensions from the Marketplace – not for local .vsix files.

The solution is to use postAttachCommand and directly call the VSCode Remote CLI:

JSON
"postAttachCommand": "/home/node/.vscode-server/bin/*/bin/remote-cli/code --install-extension /workspace/swx-time-tracker-0.0.1.vsix",

This way, the extension is automatically installed every time the Dev Container starts – without any manual steps.

Comments

Leave a Reply