Microsoft MVP성태의 닷넷 이야기
Windows: 207. Windows Server 2022에 도입된 WSL 2 [링크 복사], [링크+제목 복사],
조회: 6692
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)
(시리즈 글이 11개 있습니다.)
개발 환경 구성: 303. Windows 10 Bash Shell - 한글 환경을 영문으로 바꾸고 싶다면?
; https://www.sysnet.pe.kr/2/0/11058

개발 환경 구성: 554. WSL 인스턴스 export/import 방법 및 단축 아이콘 설정 방법
; https://www.sysnet.pe.kr/2/0/12569

개발 환경 구성: 556. WSL 인스턴스 초기 설정 명령어
; https://www.sysnet.pe.kr/2/0/12573

개발 환경 구성: 581. Windows에서 WSL로 파일 복사 시 root 소유권으로 적용되는 문제
; https://www.sysnet.pe.kr/2/0/12718

Linux: 46. WSL 환경에서 find 명령을 사용해 파일을 찾는 방법
; https://www.sysnet.pe.kr/2/0/12864

개발 환경 구성: 617. 윈도우 WSL 환경에서 같은 종류의 리눅스를 다중으로 설치하는 방법
; https://www.sysnet.pe.kr/2/0/12878

개발 환경 구성: 619. Windows Server에서 WSL을 위한 리눅스 배포본을 설치하는 방법
; https://www.sysnet.pe.kr/2/0/12882

Linux: 47. WSL - shell script에서 설정한 환경 변수가 스크립트 실행 후 반영되지 않는 문제
; https://www.sysnet.pe.kr/2/0/12918

Windows: 207. Windows Server 2022에 도입된 WSL 2
; https://www.sysnet.pe.kr/2/0/13073

개발 환경 구성: 694. Windows 디렉터리 경로를 WSL의 /mnt 포맷으로 구하는 방법
; https://www.sysnet.pe.kr/2/0/13484

Linux: 67. WSL 환경 + mlocate(locate) 도구의 /mnt 디렉터리 검색 문제
; https://www.sysnet.pe.kr/2/0/13503




Windows Server 2022에 도입된 WSL 2

서버 버전에서도 WSL 2가 가능하다는 소식이 나왔군요. ^^

WSL2 now available on Windows Server 2022
; https://techcommunity.microsoft.com/t5/itops-talk-blog/wsl2-now-available-on-windows-server-2022/ba-p/3447570

안 그래도 예전에 WSL 2 사용으로 막힌 docker-desktop 연동도 있어,

Windows Server 2022 + docker desktop 설치 시 WSL 2로 선택한 경우 "Failed to deploy distro docker-desktop to ..." 오류 발생
; https://www.sysnet.pe.kr/2/0/12879

저도 설치해봤습니다. 실제로 테스트 PC를 가보니 다음과 같이 KB5014021 업데이트가 걸려 있었고,

wsl2_on_win2022_1.png

설치 후 재부팅을 했습니다. 자... 그럼 기존 WSL 1 인스턴스를,

c:\temp> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Stopped         1

WSL 2로 변경할 수 있게 되었습니다. ^^

C:\WINDOWS\system32> wsl --set-version Ubuntu-20.04 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion complete.

C:\WINDOWS\system32> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Stopped         2




당연히, 이전에는 안 되었던 Docker Desktop의 WSL 2 지원 모드도 활용할 수 있게 되었습니다.

wsl2_on_win2022_2.png

이후, Hyper-V의 "DockerDesktopVM"은 삭제해도 되고 다음과 같이 wsl로 통합이 된 것을 확인할 수 있습니다.

C:\WINDOWS\system32> wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu-20.04           Running         2
  docker-desktop-data    Running         2
  docker-desktop         Running         2




마지막으로, Windows 11의 WSL 2 리눅스 환경에서는 WSLg 구성요소를 이용한 GUI 통합이 되었는데요, Windows Server 2022에서는 그게 가능할까요? 결론 먼저 말하면, 안 됩니다. ^^

$ gedit
Unable to init server: Could not connect: Connection refused

(gedit:8708): Gtk-WARNING **: 17:38:58.959: cannot open display:

아쉽게도 WSLg는 현재 Windows 11에서만 가능합니다. 물론 (기존의 WSL 1에서도 가능했던) 별도의 X Server 디스플레이를 연결하는 방식은 지원합니다.

ArcticaProject/vcxsrv
; https://github.com/ArcticaProject/vcxsrv

위의 프로그램(vcxsrv.exe)을 실행시키고 WSL 환경에 다음의 2가지 환경 변수를 설정해 주면,

LIBGL_ALWAYS_INDIRECT=1
DISPLAY=[..IP...]:0

이후 gedit와 같은 리눅스 GUI 프로그램이 다음과 같이 잘 실행됩니다.

wsl2_on_win2022_3.png

예를 들어, 아래와 같이 실행하면 되는데,

$ 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 172.30.192.1
$ export DISPLAY=172.30.192.1:0
$ export LIBGL_ALWAYS_INDIRECT=1
$ gedit

여기서 resolv.conf로부터 알아내는 것은 grep과 sed를 이용해 이런 식으로 자동화할 수 있습니다.

export DISPLAY="`grep nameserver /etc/resolv.conf | sed 's/nameserver //'`:0"

마지막으로 매번 설정할 필요가 없도록 ~/.bashrc에 환경 변수 설정을 추가하면 끝!




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 1/20/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 16  17  18  19  20  21  22  23  24  [25]  26  27  28  29  30  ...
NoWriterDateCnt.TitleFile(s)
13014정성태3/23/20227810VC++: 155. CComPtr/CComQIPtr과 Conformance mode 옵션의 충돌 [1]
13013정성태3/22/20226091개발 환경 구성: 641. WSL 우분투 인스턴스에 파이썬 2.7 개발 환경 구성하는 방법
13012정성태3/21/20225441오류 유형: 803. C# - Local '...' or its members cannot have their address taken and be used inside an anonymous method or lambda expression
13011정성태3/21/20226944오류 유형: 802. 윈도우 운영체제에서 웹캠 카메라 인식이 안 되는 경우
13010정성태3/21/20225855오류 유형: 801. Oracle.ManagedDataAccess.Core - GetTypes 호출 시 "Could not load file or assembly 'System.DirectoryServices.Protocols...'" 오류
13009정성태3/20/20227503개발 환경 구성: 640. docker - ibmcom/db2 컨테이너 실행
13008정성태3/19/20226801VS.NET IDE: 176. 비주얼 스튜디오 - 솔루션 탐색기에서 프로젝트를 선택할 때 csproj 파일이 열리지 않도록 만드는 방법
13007정성태3/18/20226349.NET Framework: 1181. C# - Oracle.ManagedDataAccess의 Pool 및 그것의 연결 개체 수를 알아내는 방법파일 다운로드1
13006정성태3/17/20227492.NET Framework: 1180. C# - ffmpeg(FFmpeg.AutoGen)를 이용한 remuxing.c 예제 포팅
13005정성태3/17/20226301오류 유형: 800. C# - System.InvalidOperationException: Late bound operations cannot be performed on fields with types for which Type.ContainsGenericParameters is true.
13004정성태3/16/20226285디버깅 기술: 182. windbg - 닷넷 메모리 덤프에서 AppDomain에 걸친 정적(static) 필드 값을 조사하는 방법
13003정성태3/15/20226403.NET Framework: 1179. C# - (.NET Framework를 위한) Oracle.ManagedDataAccess 패키지의 성능 카운터 설정 방법
13002정성태3/14/20227234.NET Framework: 1178. C# - ffmpeg(FFmpeg.AutoGen)를 이용한 http_multiclient.c 예제 포팅
13001정성태3/13/20227592.NET Framework: 1177. C# - 닷넷에서 허용하는 메서드의 매개변수와 호출 인자의 최대 수
13000정성태3/12/20227192.NET Framework: 1176. C# - Oracle.ManagedDataAccess.Core의 성능 카운터 설정 방법
12999정성태3/10/20226711.NET Framework: 1175. Visual Studio - 프로젝트 또는 솔루션의 Clean 작업 시 응용 프로그램에서 생성한 파일을 함께 삭제파일 다운로드1
12998정성태3/10/20226292.NET Framework: 1174. C# - ELEMENT_TYPE_FNPTR 유형의 사용 예
12997정성태3/10/202210759오류 유형: 799. Oracle.ManagedDataAccess - "ORA-01882: timezone region not found" 오류가 발생하는 이유
12996정성태3/9/202215798VS.NET IDE: 175. Visual Studio - 인텔리센스에서 오버로드 메서드를 키보드로 선택하는 방법
12995정성태3/8/20228147.NET Framework: 1173. .NET에서 Producer/Consumer를 구현한 BlockingCollection<T>
12994정성태3/8/20227410오류 유형: 798. WinDbg - Failed to load data access module, 0x80004002
12993정성태3/4/20227198.NET Framework: 1172. .NET에서 Producer/Consumer를 구현하는 기초 인터페이스 - IProducerConsumerCollection<T>
12992정성태3/3/20228669.NET Framework: 1171. C# - BouncyCastle을 사용한 암호화/복호화 예제파일 다운로드1
12991정성태3/2/20227792.NET Framework: 1170. C# - ffmpeg(FFmpeg.AutoGen)를 이용한 transcode_aac.c 예제 포팅
12990정성태3/2/20227502오류 유형: 797. msbuild - The BaseOutputPath/OutputPath property is not set for project '[...].vcxproj'
12989정성태3/2/20226982오류 유형: 796. mstest.exe - System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.Tips.WebLoadTest.Tip
... 16  17  18  19  20  21  22  23  24  [25]  26  27  28  29  30  ...