[英]VSCode Remote Container — how to open the default folder in the container instance of VSCode?
Whenever I attach VSCode to a container, it starts with no specific folder opened.每当我将 VSCode 附加到容器时,它都不会打开特定的文件夹。 I want to open folder "/ado" on start and apply the workspace settings there.
我想在开始时打开文件夹“/ado”并在那里应用工作区设置。 How can I achieve this?
我怎样才能做到这一点?
When I open the folder manually, I start in the /root folder of the container.当我手动打开文件夹时,我从容器的 /root 文件夹中开始。
.devcontainer.json: .devcontainer.json:
{
"name": "Portal Docker Environment",
"dockerComposeFile": "docker-compose.yml",
"service": "api",
"workspaceFolder": "/ado",
"cwd": "/ado",
"extensions": [
"ms-python.python",
"visualstudioexptteam.vscodeintellicode"
]
}
docker-compose.yml: docker-compose.yml:
portal:
build: Dockerfiles/portal
image: portal
command: launch_portal.py
volumes:
- ./ado:/ado
ports:
- "6543"
- "51000:51000" # for ptvsd debugger
env_file:
- ./portal.env
I also had no luck finding the complete list of possible keywords available in .devcontainer.json.我也没有找到 .devcontainer.json 中可用关键字的完整列表。 Can anyone point me in the right direction?
任何人都可以指出我正确的方向吗?
Update: Found the keyword reference for .devcontainer.json更新:找到 .devcontainer.json 的关键字参考
Got a response in the Github ticket :在Github 票证中得到了回应:
"When attaching to a running container it is not known what your current workspace folder is. Therefore the user has to pick the folder."
“当附加到正在运行的容器时,不知道您当前的工作区文件夹是什么。因此用户必须选择文件夹。”
So, attaching to a contaioner and then automatically opening a specific folder isn't possible, it seems.因此,似乎不可能附加到容器然后自动打开特定文件夹。 But I discovered that F1 Remote-Containers: Reopen Folder in Container roughly gets me where I want to go.
但我发现 F1 Remote-Containers: Reopen Folder in Container大致可以让我到达我想去的地方。
F1
Remote-Containers: Open Named Container Configuration File F1
远程容器:打开命名容器配置文件
{
"workspaceFolder": "/ado"
}
Then save, close the window and reattach it to the container.然后保存,关闭窗口并将其重新附加到容器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.