I’m using the VS Code Dev Containers extension (v0.362.0) to do my development work. I would like to automatically open a specific website in the host’s web browser after the container has started up.
After the container has booted, I can manually open a terminal and run:
xdg-open http://...
or
code --openExternal http://...
it has the desired effect: the host’s web browser opens the requested page. The xdg-open
command works because the remote extension seems to be setting the BROWSER
environment variable, which then forwards the request to VS Code itself.
So far, so good!
But I cannot achieve the same when using a postStartCommand
or postAttachCommand
in devcontainer.json
, i.e.,
"postStartCommand": {
"open-website": "code --openExternal http://..."
},
and
"postAttachCommand": {
"open-website": "code --openExternal http://..."
},
do not work.
I figured that when these commands are run, the BROWSER
variable is not (yet?) set.
I’m wondering if I’m perhaps missing something essential here? Any suggestions would be greatly appreciated.