简体   繁体   English

VSCode 远程容器 — 如何打开 VSCode 的容器实例中的默认文件夹?

[英]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.

相关问题 VSCode 远程容器默认 python 解释器 - VSCode remote-container default python interpreter 如何使用 VSCode 的远程开发扩展在容器外的 Docker 容器中打开文件 - How to open files in a Docker container outside of container using the Remote Development extension for VSCode 在 vscode 中如何设置默认容器 - in vscode how do I set the default container vscode-remote-container 在 post*Command 后打开用户终端 - vscode-remote-container open user terminal after post*Command 使用 vscode 在 docker 容器中打开一个文件 - open a file in docker container with vscode 如何在设置正确的用户时将 VSCode 附加到远程 Docker 容器 - How to attach VSCode to a remote Docker container while setting the correct user 如何从 vscode 远程容器查看 docker 日志? - How to view docker logs from vscode remote container? VSCODE如何在远程服务器docker容器的conda环境中调试python - VSCODE how to debug python in conda environment in docker container in remote server VSCode:如何通过远程服务器在 docker 容器中运行 Jupyter notebook? - VSCode: How to run a Jupyter notebook in a docker container, over a remote server? 防止 VSCode 远程容器中的 GPG 密钥共享 - Prevent GPG key sharing in VSCode Remote Container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM