0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

devcontainerで`DISPLAY": "${localEnv:DISPLAY}"が勝手に上書きされてしまう現象の対処法

Posted at

現象

devcontainer.jsonDISPLAY": "${localEnv:DISPLAY}"と設定したのにコンテナ内でDISPLAY=:1になっている(ホスト側はDISPLAY=:0)という不可解な挙動がありました.

対策

dockerコマンドやdocker-compose.yml, devcontainer.jsonなどから,

  • /tmp/.X11-unixディレクトリのマウント,
  • DISPLAY": "${localEnv:DISPLAY}"などのDISPLAY環境変数の設定
    をすべて削除します.

It seems you don't need to specify DISPLAY or WAYLAND_DISPLAY or XDG_RUNTIME_DIR in the containerEnv section of the devcontainer.json any more. They are set automatically.

Therefore removing "DISPLAY": "${localEnv:DISPLAY}" from containerEnv fixed this issue for me. It is now set correctly automatically.

In addition I had to remove:

"-v",
"/tmp/.X11-unix:/tmp/.X11-unix",
from runArgs as this is now also handled automatically, and explicitly setting it had started causing issues.

この辺の設定はdevcontainerが自動でやってくれるみたいです.むしろ変にマウントするから不具合になっている?

余談

ホストがWSL2,Windows11,Ubuntuのコンテナでそれぞれ確認しました.Ubuntuのときコンテナ内はDISPLAY=:0になっている一方で,ホストでwhoしてディスプレイ番号見たら:1でした.異なるディスプレイ番号でもOKなのはなぜ...?

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?