Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker "make dev" WSL2 support #109

Closed

Conversation

karlromets
Copy link
Collaborator

Description:
Docker networking in WSL2 requires a different approach than Linux it seems, might have issues with other OS's. After lots of testing I managed to get this setup to work, might not be the best but everything seems to work. Before I was not able to localhost port 80 nor 443, just got timed out.
Related issue

Changes made:

  • Added docker-compose-dev.wsl.yaml - same as regular one but with host networking
  • Added nginx.wsl.conf - points to 127.0.0.1 instead of service names
  • Updated Makefile to detect WSL2 and use the the WSL config file

Now:
Going to localhost works and redirects you to https://localhost which also works.

Everything else works as it did before, only when developing on windows using WSL you should now be able to access the website on https://localhost

- Makefile auto detects WSL and uses different yaml file
- Use catch all for server_name
- Add port 80
Copy link
Owner

@joshzcold joshzcold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if you can adjust the current nginx config to work with windows.

You should be able to just change localhost to 127.0.0.1 in the current configuration

access_log /var/log/nginx.access_log main;

location / {
proxy_pass http://127.0.0.1:3000/;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could just change the other nginx config to be 127.0.0.1 to make it work with windows?

It would be better if the current nginx config wasn't on localhost anyways

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to give that try and see if you can delete this duplicate one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted the nginx.wsl.conf file and tried using the original one with 127.0.0.1 instead of frontend and backend and it worked. But I'm suspicious as to if this would now work on other docker clients or does this break it?

@joshzcold
Copy link
Owner

#111

Looking at this now it looks like a misguided you in saying we could have the nginx.conf support both.

Technically we could if the original docker-compose was in host network mode, but to save some time I jsut ported over your change before I asked you to merge in the 2 nginx configs.

@joshzcold joshzcold closed this Dec 31, 2024
@karlromets karlromets deleted the feat/docker-wsl-support branch January 2, 2025 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants