- Windows 11, or Windows 10 version 1903 or higher, with Build 18362 or higher, for x64 systems, and Version 2004 or higher, with Build 19041 or higher, for ARM64 systems
- Basic linux command line understanding
- Optional: Windows terminal application
- Enable wsl2 and install
debian
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart
wsl --set-default-version 2
wsl --inistall -d Debian
-
Login into debian and create name and password for your user. To start wsl2 click
windows
button and type your distribution name and click on the icon -
Enable
sudo
priviliges for current linux user. In powershell (replace MY_USER with username you created on previous step):
wsl -d Debian --user root
usermod -aG sudo MY_USER
-
Install docker from official manual or through installation script
-
Change
/etc/wsl.conf
to allow mounting volumes from windows and autostarting docker
[boot]
command="service docker start"
[automount]
root=/
- Change
/etc/docker/daemon.json
inside to expose port for window installation
{"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}
- One of the options is to install docker-cli from chocolatey docker-cl
In order to be able to run testcontainers tests it is required to add DOCKER_HOST environment variable that directs to WSL2 machine.
- Run command in Windows powershell to obtain ip of wsl2 machine
PS C:\Users\me> wsl hostname -I
172.23.200.48 172.17.0.1 172.30.0.1
- Set environment variable in windows to the first ip address
DOCKER_HOST=tcp://172.23.200.48:2375
- Volume mounting from windows host requires providing paths in specific format.
- in git bash. It is required leading slash
/
effectively making path to look like//c/some/dir
. The command below will mount current directory to/data
inside the container
$ docker run --rm -ti -v /$(pwd):/data bash -c "ls -la /data"
- in powershell. It is required to provide paths as :
PS C:\projects\bash> docker run --rm -ti -v /c/projects/bash:/data bash -c "ls -la /data"
- in git bash. It is required leading slash