VS Code in docker container: Is there a way to automatically install extensions when connecting to a running container?

Viewed 350

When I use the "Attach to Running Container..." feature of VS Code I have to manually install the few extensions that I need installed in the container.

Attach to Running Container...

Is there a way to setup VS Code such that when I attach to a running container it automatically installs the extensions I need?

I am aware of this question: Automatically install extensions in VS Code?

But that doesn't say anything about installing extensions in running containers automatically and isn't clear on how the answers could be used to accomplish this.

The specific extension I need installed is the Python extension from Microsoft. I'm not sure that is relevant, but just in case it is.

1 Answers

You can add an array of extension ids to the 'attach' configuration ("extensions" property). Use F1 > Remote-Containers: Open Attached Container Configuration File... to open that. Note that for each container extensions will be installed only the first time you attach to it, changes to "extensions" in the config file after that will only apply to the next container with the same image name (or container name, if the config is scoped to that).

Related