# wsl .wslconfig
์ธ๋ถ์๋ฒ์ ์์ํด์์ค์ :
https://velog.io/@bluejoyq/wsl-%EC%84%9C%EB%B2%84-%EC%99%B8%EB%B6%80-%EC%A0%91%EC%86%8D%ED%95%98%EA%B8%B0
[wsl2]
memory=16GB
processors=8
swap=4GB
localhostForwarding=true
# wsl setting
# cmd ๊ด๋ฆฌ์ ๊ถํ์ผ๋ก ์งํ
# https://linux.how2shout.com/how-to-install-default-ubuntu-22-04s-desktop-environment/
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
# dism.exe /online /enable-feature /featurename:microsoft-hyper-v /all /norestart
# information
dism.exe /online /get-featureinfo /featurename:VirtualMachinePlatform
dism.exe /online /get-featureinfo /featurename:Microsoft-Windows-Subsystem-Linux
# dism.exe /online /get-featureinfo /featurename:microsoft-hyper-v-all
# unregister
dism.exe /online /disable-feature /featurename:VirtualMachinePlatform
dism.exe /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux
# dism.exe /online /disable-feature /featurename:microsoft-hyper-v-all
# linux kernel setting
https://docs.microsoft.com/ko-KR/windows/wsl/wsl2-kernel
# wsl version ์ค์
wsl --set-default-version 2
### wsl ์ญ์ ํ ์ฌ์ค์น
# https://docs.microsoft.com/ko-kr/windows/wsl/install-manual
# https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-11-with-gui-support#1-overview
# list
wsl --list --online
# install
wsl --install -d Ubuntu-20.04
# version, install list
wsl -l -v
wsl
# version ์ ํ
wsl --set-default Ubuntu-20.04
# remove
wsl --unregister Ubuntu-20.04
# enable systemd
systemd
/etc/wsl.conf
sudo vi /etc/wsl.conf
[boot]
systemd=true
wsl --shutdown
# wsl default-user (ubuntu20.04๋ ubuntu2004)
ubuntu config --default-user root
# root ๋ก๊ทธ์ธ ํ ๋น๋ฐ๋ฒํธ ๋ณ๊ฒฝ
passwd
passwd oseongryu
ubuntu config --default-user oseongryu
# wsl docker
# https://netmarble.engineering/docker-on-wsl2-without-docker-desktop/
curl -sSL get.docker.com | sh
docker --version
# sudo ๊ถํ์ค์
grep -E 'sudo|wheel' /etc/group
sudo grep -E '%sudo|%wheel' /etc/sudoers
sudo usermod -aG docker $USER
echo '' >> ~/.profile
echo '# set DOCKER_HOST for docker default context' >> ~/.profile
echo 'wsl_ip=$(ip addr show eth0 | grep -oP "(?<=inet\s)\d+(\.\d+){3}")' >> ~/.profile
echo 'export DOCKER_HOST=tcp://$wsl_ip:2375' >> ~/.profile
sudo update-alternatives --config iptables
# Press <enter> to keep the current choice[*], or type selection number: 1
wsl --shutdown
# wsl docker setting
[Environment]::GetEnvironmentVariable('DOCKER_HOST', 'Machine')
[Environment]::SetEnvironmentVariable('DOCKER_HOST', 'tcp://localhost:2375', 'Machine')
docker ์คํํ๋ก๊ทธ๋จ ์ฐ๊ฒฐ
sudo vi /etc/docker/daemon.json
---/etc/docker/daemon.json
{
"hosts": [
"fd://",
"unix:///var/run/docker.sock",
"tcp://0.0.0.0:2375"
]
}
---
sudo vi /lib/systemd/system/docker.service
---/lib/systemd/system/docker.service
#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecStart=/usr/bin/dockerd --containerd=/run/containerd/containerd.sock
---
sudo systemctl daemon-reload
sudo systemctl restart docker.service
# wsl ๋ฐฑ๊ทธ๋ผ์ด๋ ์คํ + docker mapping (์์ ์ค์ผ์ค๋ฌ์ ์ถ๊ฐํ๋ ๋ฐฉ์๋ ๊ฐ๋ฅ)
@REM Windows ๊ด๋ฆฌ์ ๊ถํ์ผ๋ก bat๋ก ์คํ
@REM wsl ๋ฐฑ๊ทธ๋ผ์ด๋์์ ๊ณ์ ์คํ์ค์ด์ด์ผ ํจ
@echo Starting dockerd in WSL ...
@echo off
for /f "tokens=1" %%a in ('wsl -d Ubuntu sh -c "hostname -I"') do set wsl_ip=%%a
netsh interface portproxy add v4tov4 listenport=2375 connectport=2375 connectaddress=%wsl_ip%
powershell.exe -Command "start-process wsl.exe -WindowStyle Hidden"
# wsl ์คํ ํ์ธ ํ๋ก์ธ์ค์ข ๋ฃ
Get-Process | Where-Object { $_.Name -like '*wsl*' }
Stop-Process -ID 9488
# wsl temp
# sudo service xrdp restart
# sudo systemctl enable --now xrdp
# sudo apt insatll xfce4-session
# free -h
# wget https://www.c-nergy.be/downloads/xrdp-installer-1.2.2.zip
# unzip xrdp-installer-1.2.2.zip
# sh xrdp-installer-1.2.2.sh