I'm wondering whether it is possible to have VS Code IntelliSense enabled when developing inside a Docker container where all the dependencies are locally installed?
Asked
Active
Viewed 5,622 times
22

customcommander
- 17,580
- 5
- 58
- 84

John Gray
- 221
- 2
- 4
-
1Im wondering have you found an answer to this? – Deryk W. King Jan 30 '18 at 21:50
-
Possible duplicate of [Install node\_modules inside Docker container and synchronize them with host](https://stackoverflow.com/questions/51097652/install-node-modules-inside-docker-container-and-synchronize-them-with-host) – Wayne Phipps Dec 02 '18 at 17:55
1 Answers
8
VS Code has recently launched its Visual Studio Code Remote - Containers extension:
The Visual Studio Code Remote - Containers extension lets you use a Docker container as a full-featured development environment. It allows you to open any folder inside (or mounted into) a container and take advantage of Visual Studio Code's full feature set.
But most importantly for your use case:
This lets VS Code provide a local-quality development experience — including full IntelliSense (completions), code navigation, and debugging — regardless of where your tools (or code) are located.
I made a screencast that shows that:
- The project is mounted inside a Docker container via VS Code itself
- An npm package ramda.js is installed from the running container
- VS Code IntelliSense is able to make suggestions even though the package was installed in the container.
Here's the relevant configuration file .devcontainer.json
at the root of the project:
{
"name": "My Project",
"image": "node:12-alpine"
}

customcommander
- 17,580
- 5
- 58
- 84
-
I'm having mixed results with this. Does your container mount `node_modules` as a volume? If you expand `node_modules` in the VScode explorer, are the subfolders visible? – defraggled Jan 02 '21 at 06:38
-
@defraggled VS Code automatically mounts the root folder in the container and opens a shell in the container (not on the host) so whatever you do there will be reflected on the host. – customcommander Jan 02 '21 at 18:27