Windows System on Linus (WSL)
Run Docker
On Windows, configure Docker to use TCP connection instead of named pipes.
- Install WSL https://learn.microsoft.com/en-us/windows/wsl/install
- Run commands
wsl --update
wsl --set-default-version 2
wsl --install --distribution Ubuntu
- Run Ubuntu WSL and install Docker
sudo apt --yes update
sudo apt --yes upgrade
sudo apt --yes autoclean
sudo apt --yes autoremove
sudo apt --yes install docker docker-compose
sudo usermod -aG docker $USER
echo "$USER ALL=(ALL) NOPASSWD: /usr/bin/dockerd" > /tmp/docker-sudoers
sudo bash -c 'cat /tmp/docker-sudoers >> /etc/sudoers'
rm /tmp/docker-sudoers
sudo bash -c 'echo "{ \"hosts\": [\"unix:///var/run/docker.sock\", \"tcp://0.0.0.0:2375\"] }" > /etc/docker/daemon.json'
- Edit Docker configuration in Ubuntu WLS
$ cat /etc/docker/daemon.json
{ "hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2375"],
"dns": ["8.8.8.8", "9.9.9.9"]
}
- Configure Windows commands to run Docker in Ubuntu WSL
C:\Windows\system32\docker.bat @echo off wsl docker %*
This path C:\Windows\system32\ should already be in PATH environment variableC:\Windows\system32\docker-compose.bat @echo off wsl docker-compose %*
- Configure Windows environment variable
DOCKER_WSL_ROOT_PATH /mnt/c
\\wsl$\Ubuntu\home\<your username>\.docker
- To: C:\Users\<your username>\.docker
- To connect to Docker get WSL IP address to Windows environment
wsl hostname -I
- Create Windows environment variables with first IP addresses outpue in this command
DOCKER_HOST tcp://172.24.93.16:2375
- Create Windows environment variables with first IP addresses outpue in this command
- Start Docker in Ubuntu WSL
sudo dockerd