Docker Desktop on Windows is bloated, it requires running Docker Desktop all the time. Not to mention all the AI stuff that is being pushed to it. Running Docker on Linux (WSL) directly is more efficient as Docker Desktop uses a Linux VM too behind the scene.
Install Arch Linux WSL distro. You will enter Arch Linux automatically when it's done downloading.
wsl --install archlinuxArch Linux in WSL uses the root account by default. This is unsafe, so we need to install sudo and create our account manually.
pacman -Sy sudo
# Just in case the group doesn't exist
groupadd sudoNow edit /etc/sudoers and uncomment wheel ALL=(ALL) ALL and %sudo ALL=(ALL) ALL.
pacman -Sy nano
nano /etc/sudoersAdd a new user account.
useradd -m -G wheel,sudo -s /bin/bash <username>
# Set the password for the user account
passwd <username>
# Set password for root too (optional but recommended)
passwd rootInstall Docker and Docker Compose.
pacman -Sy docker docker-compose
# Add our user to the Docker group
usermod -aG docker <username>If you want to use CUDA inside the Docker container, install Nvidia toolkit too. Later, when running the container, you need to add the parameter --gpus all or --runtime=nvidia.
pacman -Sy nvidia-container-toolkit
# Optional, still work in my case without setting this
nvidia-ctk runtime configure --runtime=dockerNow exit from WSL to change the default user.
exit
wsl --terminate archlinux
wsl --manage archlinux --set-default-user <username>
# Enter WSL again
wsl -d archlinuxActivate the Docker socket (per Arch wiki).
# Prevent docker socket from waiting this service
# This service doesn't work correctly in WSL
sudo systemctl disable --now systemd-networkd-wait-online.service
# Enable the actual docker socket
sudo systemctl enable --now docker.socket
# Check the status
systemctl status docker.socket
docker infoIt's done! If you need to execute docker directly from Windows, you just need to set an alias on your shell. It's much safer than exposing the Docker socket.
alias docker="wsl -d archlinux docker"
alias docker-compose="wsl -d archlinux docker-compose"For monitoring Docker easily, you can install lazydocker (CLI) or podman-desktop (GUI). I personally liked lazydocker more because it has no dependency. For other alternatives, see the Docker Arch wiki.
sudo pacman -Sy lazydocker
# To run lazydocker
lazydocker