moodlehq / moodle-docker

A docker environment for moodle developers
GNU General Public License v3.0
373 stars 244 forks source link

Issue with Windows WSL2 and latest version of moodle docker #262

Closed kiklop74 closed 1 year ago

kiklop74 commented 1 year ago

Recently I pulled latest code from this repoository and tried to install new site and everything apparently executes as it should however When I try to open the site I just get "localhost refused to connect.".

I have Windows 11 with latest Docker desktop using Ubuntu 20.04 as default distribution under WSL2.

I tried making a custom docker compose project and with that one site was working correctly

scara commented 1 year ago

Hi @kiklop74, I'm not using Docker Desktop for Windows when playing with the Moodle Docker Toolbox but I guess that you need to export the connection outside the VM hosting your Docker Engine by discovering the IP of the VM (ifconfig or ip address show eth0) and using that address as the value of the MOODLE_DOCKER_WEB_PORT env var e.g. MOODLE_DOCKER_WEB_PORT=0.0.0.0:80 to expose it regardless the actual VM IP address. Otherwise, the webserver service is bound to the localhost of the VM by default.

HTH, Matteo

kiklop74 commented 1 year ago

Thanks @scara, that solved the issue. I wonder what was different before where this thing just worked without this specific setting.

kiklop74 commented 1 year ago

Closing

scara commented 1 year ago

For Community reference,

I wonder what was different before where this thing just worked without this specific setting.

The strict bind to IPv4 localhost (127.0.0.1) is there since early 2020, a security feature of Moodle Docker Toolbox. That means that if your Docker Engine is not running on your DEV host you should customize MOODLE_DOCKER_WEB_PORT.

WSL2 is nicer but actually very different from WSL1; https://learn.microsoft.com/en-us/windows/wsl/networking could provide some details and advice.

HTH, Matteo