# 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
Last Updated: 4/13/2025, 11:14:44 PM