I was looking at Vagrant and Windows Subsystem for Linux | Vagrant | HashiCorp Developer and read the part about Docker:
The docker daemon cannot be run inside the Windows Subsystem for Linux. However, the daemon can be run on Windows and accessed by Vagrant while running in the WSL. Once docker is installed and running on Windows, export the following environment variable to give Vagrant access:
vagrant@vagrant-10:/mnt/c/Users/vagrant$ export DOCKER_HOST=tcp://127.0.0.1:2375
Is this current in light of WSL 2 and the Docker integration that is available in the latest Docker Desktop version where the Docker daemon does run under WSL. What about other WSL-specific points on that page? Does anything need updating to address recent changes?
TIA for any clarification
1 Like
To answer your first question: no. That page you linked is talking about vagrant in context of WSL version 1. In order to use with Docker with WSL version 1 you have to do this:
- Open PowerShell and run this command against the distro that you are running vagrant on to switch it over to WSL version 1.
wsl.exe --set-version (distro name) 1
To find the proper name of your distro that Windows uses, run this command from PowerShell wsl.exe -l -v
- Enable Hyper-V
- Restart Windows
- Uncheck the “Use the WSL 2 based engine” checkbox in Docker’s settings. Once Docker restarts it will now be using the Hyper-V backend instead of WSL 2.
- Check the “Expose deamon on tcp://localhost:2375 without TLS” checkbox in Docker’s settings.
- Run the following in your linux distro running vagrant as mentioned in the page you linked in your post:
export DOCKER_HOST=tcp://127.0.0.1:2375
1 Like