Hi,
While running Docker and Devilbox under WSL 2 / Ubuntu 20.04, when I create a new project folder inside the data/www folder (for example ./data/www/myproj), to access the contents of the project folder with a Windows browser, I have to first edit the Windows hosts file like so: “127.0.0.1 myproj” and then shutdown and restart WSL 2 (apparently on boot, WSL 2 regenerates the /etc/hosts and /etc/resolv.conf files, so simply editing /etc/hosts is not adequate).
Is there anything I can do to make the Devilbox vhosts / Auto DNS work, so that I don’t have to edit the Windows hosts file every time I add a new project folder? Is this something that is broken in WSL 2 and will be fixed in a few months? Is it a Windows networking / DNS issue? Is it something that is broken in Devilbox? See #9 below…
Host is Windows 10 Pro:
Microsoft Windows Version 2004 (OS Build 19041.264)
Please accept my apologies if I posted this to the wrong forum. I wanted to check here before submitting a ticket on the github cytopia issues system.
I have the following setup:
1 .env identical to env-example with the following exceptions:
LOCAL_LISTEN_ADDR=127.0.0.1:
HOST_PATH_SSH_DIR=/c/Users/myuser/.ssh
HOST_PORT_BIND=53
BIND_LOG_DNS_QUERIES=1
2 Add to Windows hosts file: c:\windows\system32\drivers\etc\hosts
127.0.0.1 myproj.loc
2 Start WSL 2
Windows-key Ubuntu 20.04 LTS
PS C:\WINDOWS\system32> wsl -l -v
NAME STATE VERSION
3 Docker installed on WSL 2; Docker Desktop NOT installed
$ sudo apt list --installed | grep docker
docker-ce-cli/focal,now 5:19.03.10~3-0~ubuntu-focal amd64 [installed]
docker-ce/focal,now 5:19.03.10~3-0~ubuntu-focal amd64 [installed]
5 Start Docker from WSL 2 terminal
$ sudo service docker start
- Starting Docker: docker [ OK ]
6 Run devilbox
cd /c/Users/myuser/code/devilbox
docker-compose up bind httpd php
7 Create project folder and index.htm file in document root
mkdir -p data/www/myproj/htdocs
cp index.htm data/www/myproj/htdocs/
8 Windows Firefox visit ‘localhost’
http://localhost/
Devilbox intranet home page is displayed
Devilbox v1.7.0 (2020-03-24)
9 Click Virtual Hosts link (vhosts.php), the following is displayed
myproj ./data/www/myproj/htdocs OK myproj.loc
Previously, when I did NOT have a myproj.loc entry in the Windows hosts file, the following was displayed:
myproj ./data/www/myproj/htdocs ERR No Host DNS record found. Add the following to /etc/hosts: 127.0.0.1 myproj.loc
11 Contents of hosts file:
$ cat /etc/hosts
This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
[network]
generateHosts = false
127.0.0.1 localhost
127.0.1.1 yoga.localdomain yoga
10.0.0.34 host.docker.internal
10.0.0.34 gateway.docker.internal
127.0.0.1 kubernetes.docker.internal
127.0.0.1 myproj.loc
The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
12 Contents of resolv.conf file
$ cat /etc/resolv.conf
nameserver 172.16.238.100
nameserver 127.0.0.1
nameserver 8.8.8.8