Menjalankan Docker di dalam WSL (Ubuntu 24.04)

0  
       

1. Hapus Aplikasi Docker

Jika anda sudah pernah install docker, silakan hapus dulu supaya tidak conflict.

2. Pastikan WSL sudah terinstall

Setelah itu pastikan bahwa WSL sudah terinstall dan sudah bisa menjalankan Ubuntu-24.04 di dalam WSL

3. Install docker

# Add Docker’s official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
“deb [arch=$(dpkg –print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo “${UBUNTU_CODENAME:-$VERSION_CODENAME}”) stable” | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

4. Tambahkan current user ke groupnya docker

sudo usermod -aG docker $USER

5. Adjust pengaturan WSL

sudo nano /etc/wsl.conf

# Added these 2 lines:
[network]
generateResolvConf = false

6. Keluar dari WSL dan restart WSL

exit

wsl –shutdown

wsl -d Ubuntu-24.04

7. Perbarui Nameserver

sudo nano /etc/resolv.conf

# Ganti name server yang sudah ada
nameserver 1.1.1.1

8. Test docker

docker run hello-world

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>