cytopia / devilbox

A modern Docker LAMP stack and MEAN stack for local development
http://devilbox.org
MIT License
4.4k stars 654 forks source link

Devilbox + docker + WSL in Windows 10 Pro. 19H1 #604

Closed keldrox closed 2 years ago

keldrox commented 5 years ago

I have been using Devilbox in Windows 10 correctly but the symfony projects work very slowly.

That's why I used WSL with the tutorial https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly

Everything works correctly but Devilbox shows me "Forbidden" when entering localhost and AH00112 appears in the console: Warning: DocumentRoot [/ var / www / default / htdocs /] does not exist

Do you have any idea of making it work?

Thank you.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

cytopia commented 5 years ago

I would suppose there has been a mounting issue and nothing was actually mounted into the container. You could confirm this in the httpd and php container by doing:

docker-compose exec httpd ls -la /var/www/
docker-compose exec httpd ls -la /var/www/default/

docker-compose exec httpd ls -la /shared/httpd/
docker-compose exec php ls -la /var/www/
docker-compose exec php ls -la /var/www/default/

docker-compose exec php ls -la /shared/httpd/
yudhir commented 4 years ago

very slow 2000ms minimum on Refresh and cache hit pages too. wsl2

yudhir commented 4 years ago

Only way to make it Faster , is to use Remote Plugin of VSCODE to store the Code in the WSL2 Filesystem itself . But I don't know if Devilbox works properly .

cytopia commented 4 years ago

@yudhir are you using WSL 2 natively, also without VSCODE?

https://www.thomasmaurer.ch/2019/08/run-linux-containers-with-docker-desktop-and-wsl-2/

yudhir commented 4 years ago

Yes , natively as I use Phpstorm IDE. I wanted to make it work on Windows , but too slow. New changes of gRPC FUSE didn't make discernible changes . https://docs.docker.com/docker-for-windows/edge-release-notes/

Mayebe if var/Vendor folder are left in the container , but PHP code features won't work .

cytopia commented 4 years ago

Unfortunately I don't have a Windows to test this out. However in the forums there is one user for whom it seems to work really nicely. Try to ping him there: https://devilbox.discourse.group/t/devilbox-on-windows-10-my-best-experience/231

yudhir commented 4 years ago

Docker for Windows itself has no issues . It is as optimised as installing Docker inside WSL2 like the Link above . Problem arises with the Code and Cache , var/vendor being on the Windows Filesystem , which needs to be, for IDE to work .

Using VSCODE and Remote WSL plugin is the right solution . But it won't work for other IDE .

llaville commented 4 years ago

Hello all,

I've bought recently a new PC (Windows 10 Pro) and i've tried the WSL 2 support through Insider Preview Program Build 19551.rs_prerelease.200118-2023

While installation of Devilbox and usage with CLI run fines, i've an issue when trying to use the web mode and vhosts.

I've follow for installation the good article linked in https://devilbox.discourse.group/t/devilbox-on-windows-10-my-best-experience/231 as @cytopia suggested !

I've added my new vhosts in C:\Windows\System32\drivers\etc\hosts and started the Ubuntu 18.04 LTS distro as recommanded in https://github.com/microsoft/WSL/issues/2059

BTW, after running docker-compose up -d to start all default containers (no custom added) i've checked my /etc/hosts file and saw all new vhosts added from Windows etc hosts file.

But when i started the php container, no vhosts were added to /etc/hosts

So i've decided to add it manually with root account ( sudo su - ) and tried to see my new vhosts with http://localhost/vhosts.php But I always get error

No Host DNS record found. Add the following to /etc/hosts:
127.0.0.1 doctrine-audit-bundle-demo.local

For example. My Devilbox .env file has TLD_SUFFIX=local

Is someone can help me. This is my first experience with WSL. Under native Linux distro, i got no problems.

Thanks

vikas5914 commented 4 years ago

Hi,

I know this is little bit of the issue but recently docker released a WSL 2 Backend. I tried on my pc and its works great and solve problem that you guys are having.

https://www.docker.com/blog/new-docker-desktop-wsl2-backend/

keldrox commented 4 years ago

Good @llaville

Try adding in your / etc / hosts

127.0.0.1 doctrine-audit-bundle-demo.local ::1 doctrine-audit-bundle-demo.local

Although the error message appears when entering doctrine-audit-bundle-demo.local it should work

regards

llaville commented 4 years ago

@keldrox sorry but your tip does not work !

llaville commented 4 years ago

@keldrox sorry finally it works. I've made a mistake.

We should edit the C:\Windows\System32\drivers\etc\hosts with double entries

127.0.0.1 doctrine-audit-bundle-demo.local
::1 doctrine-audit-bundle-demo.local

Then in Ubuntu 18.04 LTS distro, the /etc/hosts is automatically copied. But we still need to edit (in root mode) the etc/hosts in php container that is not updated.

And yes finally the vhost is configured !!!

llaville commented 4 years ago

@cytopia how can we simplified /etc/hosts synchonization between host (Linux under WSL) and php container ?

llaville commented 4 years ago

@cytopia Forgot my previous comment; its useless, because /etc/hosts inside php container is not used with this platform context (Windows + WSL 2 + Ubuntu 18.04 LTS distro)

cytopia commented 4 years ago

The /etc/hosts file inside the PHP container should actually not be required, as the container is using DNS records from BIND: https://github.com/cytopia/devilbox/blob/master/docker-compose.yml#L153

This however is purely for communication from within the PHP container.

If communication from the host, you either configure auto-dns or your hosts file on the host os.

So if the following entries on the Windows host work for you...

127.0.0.1 doctrine-audit-bundle-demo.local
::1 doctrine-audit-bundle-demo.local

...that means it is now somehow also requiring IPv6.

@llaville can you confirm again, that this works for you?

llaville commented 4 years ago

@cytopia I confirm that with editing Windows hosts file and adding IPV6 format (::1 doctrine-audit-bundle-demo.local) work for me ! Without IPV6, it does not run

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

MrSnoozles commented 4 years ago

@llaville Have you managed to get AutoDNS to work with WSL2?

llaville commented 4 years ago

@MrSnoozles No I didnt managed AutoDNS

cytopia commented 4 years ago

Re-opening this one, as it is not fully fixed yet for AutoDNS

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

llaville commented 4 years ago

I've tried to solve this on my side but still have issue. Here is what I did

that will avoid WSL to generate /etc/hosts and /etc/resolv.conf files on the linux distribution.

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


Follow AutoDNS instructions at https://devilbox.readthedocs.io/en/latest/intermediate/setup-auto-dns.html#setup-auto-dns

* Set port 53 to `HOST_PORT_BIND` in your `.env`

With a `docker-compose.override.yml` with at least such contents

version: '2.3'

services:

bind: image: cytopia/bind:0.17 environment:

Logs gave as expected

llaville@LAPTOP-7JMHIOJJ:~/.devilbox$ docker-compose logs bind
Attaching to devilbox_bind_1
bind_1   | [INFO] Debug level: 2
bind_1   | [INFO] BIND logging: to stderr via Docker logs
bind_1   | [INFO] Using default DNS TTL time: 3600 sec
bind_1   | [INFO] Using default DNS Refresh time: 1200 sec
bind_1   | [INFO] Using default DNS Retry time: 180 sec
bind_1   | [INFO] Using default DNS Expiry time: 1209600 sec
bind_1   | [INFO] Using default DNS Max Cache time: 10800 sec
bind_1   | [INFO] Adding wildcard DNS: *.local -> 127.0.0.1
bind_1   |
bind_1   | zone local/IN: loaded serial 1605198050
bind_1   | OK
bind_1   | [INFO] Not adding any extra hosts
bind_1   | [INFO] Adding custom allow-query options: any
bind_1   | [INFO] Adding custom allow-recursion options: localnets,localhost
bind_1   | [INFO] DNSSEC Validation: no
bind_1   | [INFO] Adding custom DNS forwarder: 8.8.8.8,8.8.4.4
bind_1   | [INFO] Starting BIND 9.11.5

Even when I visit the http://localhost/vhosts.php page, vhosts addresses are resolved i.e: with one of my vhosts

bind_1   | 12-Nov-2020 16:21:20.727 client @0x7f4bf01bc9b0 172.16.238.10#43830 (dvlbox-intranet.local): query: dvlbox-intranet.local IN A + (172.16.238.100)

Confirmed with following commands

llaville@LAPTOP-7JMHIOJJ:~/.devilbox$ nslookup dvlbox-intranet.local
Server:         172.16.238.100
Address:        172.16.238.100#53

Name:   dvlbox-intranet.local
Address: 127.0.0.1

And

llaville@LAPTOP-7JMHIOJJ:~/.devilbox$ dig dvlbox-intranet.local

; <<>> DiG 9.11.3-1ubuntu1.11-Ubuntu <<>> dvlbox-intranet.local
;; global options: +cmd
;; Got answer:
;; WARNING: .local is reserved for Multicast DNS
;; You are currently testing what happens when an mDNS query is leaked to DNS
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3920
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 703101d66914f2944fc70af25fad62b8f195b286b10bef1e (good)
;; QUESTION SECTION:
;dvlbox-intranet.local.         IN      A

;; ANSWER SECTION:
dvlbox-intranet.local.  3600    IN      A       127.0.0.1

;; AUTHORITY SECTION:
local.                  3600    IN      NS      ns2.local.
local.                  3600    IN      NS      ns1.local.

;; ADDITIONAL SECTION:
ns1.local.              3600    IN      A       127.0.0.1
ns2.local.              3600    IN      A       127.0.0.1

;; Query time: 0 msec
;; SERVER: 172.16.238.100#53(172.16.238.100)
;; WHEN: Thu Nov 12 17:28:40 CET 2020
;; MSG SIZE  rcvd: 162

But still get

No Host DNS record found. Add the following to /etc/hosts:
127.0.0.1 dvlbox-intranet.local
IlanVivanco commented 3 years ago

Facing the same issue as @llaville here.

wp4nuv commented 3 years ago

I'm not sure if this helps anyone here, but I found that Auto DNS works when you update the WSL2 adapter's DNS to 127.0.0.1. Instructions on the documentation page refer to using Docker with Hyper-V. Making this change made all resources visible to the devilbox VirtualHosts tab. UPDATE - 2021-04-22 - I wanted to add a bit more on the conversation, as it may be important to those of us who use Devilbox as an official work tool for development. Currently, bind does not function correctly when connected to a VPN or at least, to the VPN I use for work. I've tried adding the VPN DNS entries to .env, altered the resolv.conf at run time to include them etc. This goes beyond AutoDNS as it actually works in Windows 10 with the WSL backend and adding 127.0.0.1 to the virtual adapter for WSL. I'll update again if I have a solution to this.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

plumrocket commented 3 years ago

Why not use Docker on Ubuntu + WSL? You won't have any issues with it. Follow this tutorial: or watch this video: https://www.youtube.com/watch?v=9-vY5nLJC00

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

nickchomey commented 2 years ago

For anyone else that comes here, it seems to work for me by just adding 127.0.0.1 xyz.loc in the windows hosts file at C:\Windows\System32\drivers\etc\hosts