Devcontainer extension misses $DISPLAY for X11 forwarding

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

A problem in the Dev Containers extension.

It seems to support X11 forwarding but in a misconfigured state. Specifically $DISPLAY environment variable is missing. Merely setting export DISPLAY=:1 makes it work.

For comparison VSCode devcontainer extension does not have this quirk and supports X11 forwarding flawlessly.

Steps to Reproduce

Try install and run glxgears.

Expected Behavior

It should work without explicitly setting the variable like DISPLAY=:1 glxgears.

Operating System

Linux

Version Information

Version: 2.6.21
VSCode Version: 1.105.1
Commit: fea2f546c979a0a4ad1deab23552a43568807590
Date: 2026-03-21T22:09:10.098Z
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Linux x64 6.8.0-100-generic

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the report. You’re right, this is a bug. The devcontainer extension doesn’t pass $DISPLAY from the host into the container. A similar fix was already done for Remote SSH, but devcontainers were missed.

For now, the workaround is what you found. Set export DISPLAY=:1 inside the container. You can automate it via postStartCommand in devcontainer.json:

"postStartCommand": "export DISPLAY=:1"

Or via remoteEnv:

"remoteEnv": {
  "DISPLAY": "${localEnv:DISPLAY}"
}

I’ve shared this with the team. No ETA yet, but your report helps with prioritization. Let me know if the workaround doesn’t work.

1 Like

Hey @Myungbae_Son I am Tarun from the extensions team.

I am trying to reproduce the issue, but seems like i am missing something.

So i am on Mac (local) and open a devcontainer with the config

  "name": "x11 testing",
  "image": "ubuntu:22.04",
  "postCreateCommand": "apt update && apt install -y x11-apps mesa-utils && export DISPLAY=:1"

To begin with vscode, i reopen the project in container and do echo $DISPLAY and it returns nothing, doing glxgears returns Error: couldn't open display (null) .
I have XQuartz installed locally.

What am I missing ? or should i try on linux (locally) ?

Hello @Tarun_Kumar_S, I’ve never tried X11 forwarding in Mac so please try in Ubuntu or WSL.

I can see that the following sequence works in vscode:

{
	"name": "Debian",
	"image": "mcr.microsoft.com/devcontainers/base:trixie"
}
  • Open in devcontainer then run terminal
vscode ➜ /workspaces/test-devcontainer $ echo $DISPLAY
:0
vscode ➜ /workspaces/test-devcontainer $ sudo apt update && sudo apt install mesa-utils --no-install-recommends
# ...
vscode ➜ /workspaces/test-devcontainer $ glxgears
# works

Currently I’m reproducing it in WSL with Ubuntu guest & Docker Desktop on WSL2 backend. In my workplace it’s Ubuntu machine with Docker CE, but I don’t think vscode behaves differently from there. I can try on Monday (KST) if you want a full coverage.

Got it!
Was able to reproduce on WSL, and i have fixed the issue (recording here)

Should be live on the next version of the dev container extension.

Thanks again for reporting Myungbae Son!
appreciate it!
gomawohaneun!!

2 Likes