Created
January 9, 2026 00:42
-
-
Save bikcrum/27254de8c4bf212de899cca6e49aff37 to your computer and use it in GitHub Desktop.
How to change display dynamically in the docker container? For example, host display changes upon reboot.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Inside the container, edit /root/.bashrc and add this at the very bottom: | |
| # --- Fix DISPLAY for IDE-attached shells --- | |
| # Prefer the newest X socket (usually the active desktop) | |
| for d in /tmp/.X11-unix/X*; do | |
| n="${d##*/X}" | |
| export DISPLAY=":$n" | |
| done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment