Note: This is not asking for extension recommendations.
I recently started exploring the use of Dev Containers for my next Python+NodeJS+PostgreSQL project, and am trying to understand the customizations => extensions part of .devcontainer.json. For example, after auto-generating the configuration file, this is what's in there currently:
"customizations": {
"vscode": {
"extensions":["ms-python.python", "njpwerner.autodocstring"]
}
}How do I evaluate which other extensions currently installed in the host need to be installed locally inside the container, and which don't?
Settings can be added in the settings section of vscode .
"customizations": {
"vscode": {
"settings": {
"git.autofetch": true,
},
"extensions": [
"snowflake.snowflake-vsc"
]
}
}
You cannot directly define extension settings in the devcontainer.json. But if you need these settings to be version controlled and persistent, they can be defined in .vscode/settings.json
{
"git.autofetch": true
}
According to the Visual Studio Code documentation, the two files need to be located in a directory .devcontainer in the workspace root.
I still had issues installing the extensions while working from behind a corporate proxy. The solution was to give the container access to the proxy server:
If you use an authenticating proxy like Cntlm on your local machine, configure it to listen on 172.17.0.1 (the Docker interface). Then define the http_proxy and https_proxy environment variables for the container. For example, in devcontainer.json:
"containerEnv": {
"http_proxy": "http://172.17.0.1:3128",
"https_proxy": "http://172.17.0.1:3128"
}
Or in docker-compose.yaml
services:
devcontainer:
environment:
http_proxy: http://172.17.0.1:3128
https_proxy: http://172.17.0.1:3128
Or configure docker-compose.yaml to make the container use the host network:
services:
devcontainer:
network_mode: host
Then you can just pass the same proxy variables into the container as used on the host. For example, in the docker-compose.yaml:
services:
devcontainer:
environment:
http_proxy: $http_proxy
https_proxy: $https_proxy
If you are not using a local, but rather a remote proxy inside of your network, you can do the latter regardless of the container's network configuration (host or default).
I also have issues installing the extensions while working from behind a corporate proxy. The solution was to give the container access to the proxy server and set HTTP proxy strict SSL:
"settings": {
"http.proxy": "(your_proxy_host:port)",
"http.proxyStrictSSL": false
},
Hello, I'm working on a project using Docker and VS Code. When I build my docker image and run a container with the docker-compose.yml configuration, it works just fine, but when I try to add some extensions to the container using the devcontainer.json, I get the pop-up to reopen my workspace in the container, but there are no extensions installed. I am working with the latest VS Code version (1.95.3) in Windows 11. My image is built over an Ubuntu 22.04 LTS image. I've seen some Github issues related to mine but it doesnt seem to work for me.
https://github.com/microsoft/vscode-remote-release/issues/8097
https://stackoverflow.com/questions/75562662/vscode-dev-container-doesnt-install-extensions-behind-corporate-proxy
https://github.com/microsoft/vscode-remote-release/issues/6268
This is my devcontainer.json:
{
"name": "vcg_dev",
"dockerComposeFile": ["../docker-compose.yml"],
"service": "ros2",
"workspaceFolder": "/workspace",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"twxs.cmake",
"ms-iot.vscode-ros",
"smilerobotics.urdf",
"eamodio.gitlens",
"ms-azuretools.vscode-docker",
"ms-vscode.remote-containers",
"redhat.vscode-yaml",
"yzhang.markdown-all-in-one",
"streetsidesoftware.code-spell-checker",
"wayou.vscode-todo-highlight",
"gruntfuggly.todo-tree"
],
"settings": {
"python.defaultInterpreterPath": "/usr/bin/python3",
"python.analysis.typeCheckingMode": "basic",
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"cmake.configureOnOpen": true,
"extensions.verifySignature": false
}
}
},
"remoteUser": "root",
"overrideCommand": false,
"forwardPorts": [8765]
}Any help would be very appreciated!
Are you able to manually install extensions after it is built? If so, I had similar issue that was solved by adding the following environment var to docker-compose.yml:
environment:
- NODE_EXTRA_CA_CERTS=<path/to/certificate>
This post provides additional context.
My solution to this problem was to add an environment variable as a remoteEnv in .devcontainers.json file.
{
....
"remoteEnv": {
"NODE_TLS_REJECT_UNAUTHORIZED": "0"
},
"image": "mcr.microsoft.com/azure-dev-cli-apps:latest",
....
}