When attaching to a running container, use the definitions of devcontainer.json
I noted that even with some defined attributes, it does not opens on the folder I want (/src/remoteproject) neither installs the extension I want (the cpptools) when I click on Attach to running container. My devcontainer.json is the following:
{
"name": "Load image",
"context": "..",
"image": "my-custom-image",
"extensions": ["ms-vscode.cpptools"],
"workspaceFolder": "/src/remoteproject",
}
I would like to avoid opening manually the remote folder and clicking on the install extension on container . It is possible to VS Code to opens on the remote container with the defined directory and extensions installed when clicking on Attach to running container?
Moving to vscode-remote-release as this is a feature request.
Since the attach workflow has no knowledge of where the source code is coming from nor whether the source code is even in the container, it does not pick up devcontainer.json.
Out of curiosity, what is it that you would like to do that using the devcontainer.json flow does not allow, but the attach workflow does?
Thanks @Chuxel for pointing to the right place! I have tried to do the devcontainer.json flow, but I got some errors (it can´t starts the container). So I thought that attaching would be an easier way, with some defined env variables (defined by a script that I uses to start the container image). And by this way, I don´t get errors. Should I open another issue about my problems with devcontainer.json flow? Or I post here?
@cyberdecker Probably worth using a separate issue in this repo if you think you'd still like this feature. That said, if you wouldn't want this feature if devcontainer.json flow was working, we could either reclassify it or close it.
I think that it is a useful feature anyway. For the other problem, I referenced on issue #651 . Thanks!
This feature is a must!
We have a quite involved process of starting a local docker container, so there is no option for me to use devcontainer.json. I want to attach to an existing running container and I want to customize this process. I would like to have some type of attach settings file (say, devattach.json) where I could specify:
- Folder to work in.
- User to work under.
- Local paths of extensions to bring inside the container
- Script to run on attach
- Script to run on detach
The reason for this request is because I don't like my current workflow. I had to
- Open VSCode
- Open VSCode docker extension
- Find my container
- Attach to it
- Wait for extensions to install
- Select a folder I'm planning to work in,
- Switch user from root to my user.
This is too much hassle for such a frequent routine.
This was added into the last release of VS Code. 🎉
Check out info on it here: https://code.visualstudio.com/docs/remote/containers#_attached-container-configuration-files