fea*_*eoc 3 docker visual-studio-code vscode-remote
我无法使用“远程 - 容器”在开发容器中安装扩展。我不知道这是一个错误,我的配置不正确,还是预期的行为。下面是我当前的配置,这两个文件都位于项目的根文件夹中。
docker-compose.yml
version: "3.7"
services:
api:
image: node:12
restart: always
ports:
- ${API_PORT}:3000
volumes:
- .:/usr/app
- /usr/app/node_modules
working_dir: /usr/app
command: bash -c "yarn && yarn dev"
Run Code Online (Sandbox Code Playgroud)
.devcontainer.json
version: "3.7"
services:
api:
image: node:12
restart: always
ports:
- ${API_PORT}:3000
volumes:
- .:/usr/app
- /usr/app/node_modules
working_dir: /usr/app
command: bash -c "yarn && yarn dev"
Run Code Online (Sandbox Code Playgroud)
中列出的扩展列表.devontainer.json是我想安装在开发容器中的扩展。任何帮助表示赞赏!
小智 6
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"
}
Run Code Online (Sandbox Code Playgroud)
Or in docker-compose.yaml
"containerEnv": {
"http_proxy": "http://172.17.0.1:3128",
"https_proxy": "http://172.17.0.1:3128"
}
Run Code Online (Sandbox Code Playgroud)
Or configure docker-compose.yaml to make the container use the host network:
services:
devcontainer:
environment:
http_proxy: http://172.17.0.1:3128
https_proxy: http://172.17.0.1:3128
Run Code Online (Sandbox Code Playgroud)
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:
network_mode: host
Run Code Online (Sandbox Code Playgroud)
如果您使用的不是本地代理,而是网络内部的远程代理,则无论容器的网络配置(主机或默认)如何,您都可以执行后者。
| 归档时间: |
|
| 查看次数: |
1622 次 |
| 最近记录: |