microsoft / microsoft/vscode-remote-release

Opening the host's browser automatically after Dev Container startup

Open
#9,935 12 comments 1 reaction 1 assignee View on GitHub

@chrmarti is already working on this.

Since May 29, 2024.

containers feature-request
Dominant language
Dockerfile
Stars
4.2k
Forks
469
Avg merge
1d 1h
Merged PRs (30d)
1

Description

Note: I had previously posted this question on StackOverflow, but not received any response.

I'm using the 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://...

As expected, the host's web browser will open 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: nothing seems to happen.

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.