xxxxxxxxxx
# Open PowerShell as Administrator and run the following command to enable WSL 2
wsl --set-version <DistributionName> 2
# Install Docker Desktop for Windows (based on WSL 2 integration)
# You can download it from the official Docker website: https://www.docker.com/products/docker-desktop
# Open WSL terminal (e.g., Ubuntu) and run the following commands to configure Docker
sudo apt-get update
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
xxxxxxxxxx
#Refresh and install packages
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common libssl-dev libffi-dev git wget nano
#Add user group
sudo groupadd docker
sudo usermod -aG docker ${USER}
#Add docker key and repo
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
#Install docker and docker-compose
sudo apt-get install -y docker-ce containerd.io docker-compose
#Install docker-compose (if the previous command failed to install)
sudo curl -sSL https://github.com/docker/compose/releases/download/`curl -s https://github.com/docker/compose/tags | grep "compose/releases/tag" | sed -r 's|.*([0-9]+\.[0-9]+\.[0-9]+).*|\1|p' | head -n 1`/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose
xxxxxxxxxx
# To Install docker and portainer on wsl, follow these instructions
# 1. https://docs.microsoft.com/en-us/windows/wsl/install
# 2. https://docs.docker.com/engine/install/ubuntu/
# 3.
sudo service docker start
sudo service docker status
# 4. Prevent user from always having to run docker command as sudo
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
# 5. Test docker
docker run hello-world
# 6. https://docs.portainer.io/start/install/server/docker/wsl
# 7. Setup docker to start on wsl start - https://stackoverflow.com/a/65814529/9034699
# - https://techbrij.com/wsl-2-ubuntu-services-windows-10-startup
echo 'wsl.exe -u root -e sh -c "service docker status || service docker start"' > ~/.profile
xxxxxxxxxx
# NOTE: YOU MUST BE ON Windows 11 with Latest BUILD
# run this command in your linux shell
sudo echo -e "[boot]\nsystemd=true" > /etc/wsl.conf
# then run this in powershell & wait 10 seconds for everything to shutdown
wsl --shutdown
# then just re open your WSL2 Linux Distro & install docker as you normally would
sudo apt install docker docker-compose -y