Whenever I attach VSCode to a container, it starts with no specific folder opened. I want to open folder "/ado" on start and apply the workspace settings there. How can I achieve this?

When I open the folder manually, I start in the /root folder of the container.

.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:

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. Can anyone point me in the right direction?


Update: Found the keyword reference for .devcontainer.json

1 Answers

0
thomiel On

Got a response in the Github ticket:

"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.