Ubuntu(WSL2) 인스턴스에서 GUI 애플리케이션을 실행할 수 없습니다.

Ubuntu(WSL2) 인스턴스에서 GUI 애플리케이션을 실행할 수 없습니다.

MS-Windows 10에서 "Linux용 Windows 하위 시스템" 기능을 활성화하고 Ubuntu-20.04를 설치했습니다. 하나는 WSL1을 사용하고 다른 하나는 WSL2를 사용합니다. 또한 VcXsrv 도구가 MS-windows 컴퓨터에 설치되어 실행됩니다.

WSL1 지원 인스턴스에서 GUI 애플리케이션을 실행할 수 있지만 WSL2 지원 인스턴스에서는 GUI 애플리케이션을 실행할 수 없습니다. 그것은 말한다"오류: 디스플레이를 열 수 없습니다: :0.0"

아래에서 호스트 및 Linux 인스턴스에 대한 일부 출력을 찾으십시오.

Windows 10부터:

❯ ipconfig

Windows IP Configuration
Ethernet adapter Ethernet 4:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Ethernet adapter Ethernet:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Ethernet adapter vEthernet (WSL):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::102:a949:2437:16e9%55
   IPv4 Address. . . . . . . . . . . : 172.23.224.1
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :

Wireless LAN adapter Local Area Connection* 10:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Local Area Connection* 11:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::a5b7:d11b:52b0:23d6%9
   IPv4 Address. . . . . . . . . . . : 192.168.1.4
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : fe80::1%9
                                       192.168.1.1

Ethernet adapter Bluetooth Network Connection:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

❯ wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Running         2
  Ubuntu          Running         1

우분투(WSL1)에서- UI 앱이 잘 작동합니다(예: xclock, xeyes).

$ ifconfig -a
eth0: flags=64<RUNNING>  mtu 1500
        inet 169.254.226.136  netmask 255.255.0.0
        inet6 fe80::b0cd:dad8:df85:e288  prefixlen 64  scopeid 0xfd<compat,link,site,host>
        ether 80:19:34:d2:45:55  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=64<RUNNING>  mtu 1400
        inet 10.83.242.31  netmask 255.255.255.255
        inet6 fe80::d8f9:f80:42f7:4681  prefixlen 64  scopeid 0xfd<compat,link,site,host>
        ether 02:50:41:00:00:01  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth2: flags=64<RUNNING>  mtu 1500
        inet 169.254.8.40  netmask 255.255.0.0
        inet6 fe80::41af:dac3:4f41:828  prefixlen 64  scopeid 0xfd<compat,link,site,host>
        ether 34:e6:d7:1f:97:fc  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.23.224.1  netmask 255.255.240.0  broadcast 172.23.239.255
        inet6 fe80::102:a949:2437:16e9  prefixlen 64  scopeid 0xfd<compat,link,site,host>
        ether 00:15:5d:f7:dc:5c  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth4: flags=64<RUNNING>  mtu 1406
        unspec [NONE SET]  netmask 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
        ether 00:05:9a:3c:7a:00  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth5: flags=64<RUNNING>  mtu 1300
        unspec [NONE SET]  netmask 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
        ether 02:05:85:7f:eb:80  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 1500
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0xfe<compat,link,site,host>
        loop  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wifi0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.4  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::a5b7:d11b:52b0:23d6  prefixlen 64  scopeid 0xfd<compat,link,site,host>
        ether 80:19:34:d2:45:51  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wifi1: flags=64<RUNNING>  mtu 1500
        inet 169.254.12.30  netmask 255.255.0.0
        inet6 fe80::551a:4119:9646:c1e  prefixlen 64  scopeid 0xfd<compat,link,site,host>
        ether 80:19:34:d2:45:52  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wifi2: flags=64<RUNNING>  mtu 1500
        inet 169.254.80.242  netmask 255.255.0.0
        inet6 fe80::7548:77de:4bf6:50f2  prefixlen 64  scopeid 0xfd<compat,link,site,host>
        ether 82:19:34:d2:45:51  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

$ echo $DISPLAY
:0.0

$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 192.168.1.1
nameserver fec0:0:0:ffff::1
nameserver fec0:0:0:ffff::2

Ubuntu-20.04(WSL2)부터 시작: UI 애플리케이션이 작동하지 않음(예: xclock, xeyes)

❯ ifconfig -a
bond0: flags=5122<BROADCAST,MASTER,MULTICAST>  mtu 1500
        ether ba:e3:e3:6e:20:3d  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

dummy0: flags=130<BROADCAST,NOARP>  mtu 1500
        ether be:be:bb:8a:8f:a0  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.94.115  netmask 255.255.240.0  broadcast 172.17.95.255
        inet6 fe80::215:5dff:fe8e:25e5  prefixlen 64  scopeid 0x20<link>
        ether 00:15:5d:8e:25:e5  txqueuelen 1000  (Ethernet)
        RX packets 34  bytes 4988 (4.9 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12  bytes 936 (936.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2  bytes 100 (100.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2  bytes 100 (100.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

sit0: flags=128<NOARP>  mtu 1480
        sit  txqueuelen 1000  (IPv6-in-IPv4)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

❯ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 192.168.1.1
nameserver 172.17.80.1

GUI 애플리케이션에 액세스하려고 할 때 WSL2 오류:

❯ xeyes
Error: Can't open display: :0.0

❯ echo $LIBGL_ALWAYS_INDIRECT
1

❯ echo $DISPLAY
:0.0

노트:또한 다른 IP(192.168.1.1, 192.168.1.4)를 WSL2 인스턴스의 DISPLAY 변수로 내보내려고 시도했지만 아무 도움이 되지 않았습니다.

추가 정보:

  • WSL1(Ubuntu) 인스턴스에서 호스트의 IP 주소(192.168.1.4)를 성공적으로 ping할 수 있었습니다. 또한 포트 6000(vcxsrv)에 대한 텔넷도 연결됩니다.
  • 그러나 WSL2(Ubuntu) 인스턴스에서는 호스트의 IP 주소(192.168.1.4)를 ping할 수 없습니다. 게다가 포트 6000으로 텔넷을 하면 경로가 없다고 나옵니다.
  • 모든 단계를 따랐습니다.이 스레드에서 언급된여기에는 포트 6000에 대한 방화벽 규칙을 추가하는 것이 포함되었지만 문제가 해결되지는 않은 것 같습니다.

WSL1에서:

$ telnet 192.168.1.4 6000
Trying 192.168.1.4...
Connected to 192.168.1.4.
Escape character is '^]'.

WSL2에서:

❯ telnet 192.168.1.4 6000
Trying 192.168.1.4...
telnet: Unable to connect to remote host: No route to host

문의/도움말:

  • 네트워크가 달라지나요? WSL1 및 WSL2 설정은 어떻습니까? 그렇다면 현재 직면한 문제를 어떻게 해결할 수 있으며 WSL2 인스턴스에서 GUI 애플리케이션을 실행하는 방법은 무엇입니까?

  • WSL2 인스턴스에서는 호스트를 ping할 수 없습니다. 마찬가지로 WSL2 인스턴스는 호스트에서 ping할 수 없습니다.

답변1

.bashrc파일에는 다음 줄이 포함되어 있습니다. 어쩌면 이 줄을 살펴보고 export DISPLAY필요한 경우 디스플레이를 반영하도록 수정할 수도 있습니다.

# Added code for Windows Xwinrc
export DISPLAY=:0;
#export DISPLAY=localhost:0.0
#export LIBGL_ALWAYS_INDIRECT=1
#export GDK_DPI_SCALE=1

관련 정보