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

Multiple separated instances #1856

Closed
Nox-404 opened this issue Apr 6, 2017 · 18 comments
Closed

Multiple separated instances #1856

Nox-404 opened this issue Apr 6, 2017 · 18 comments

Comments

@Nox-404
Copy link

Nox-404 commented Apr 6, 2017

Would it be possible to have multiple instances of linux running ?
Each instances having their own fs and their own init process.

For example a user could develop a ruby app in an instance and have another one to run tests without messing up is dev environment.

I think that it could be a great feature, being able to trash a linux instance without trashing your own dev environment.

@aseering
Copy link
Contributor

aseering commented Apr 6, 2017

I'm curious -- what sort of app are you developing that would conflict on the process list but would not conflict on TCP ports?

@Nox-404
Copy link
Author

Nox-404 commented Apr 6, 2017

I thought about it and I don't see any workaround for now, but if you don't use the same ports it's fine...
I don't know if Microsoft plan to isolate the network and add a layer there...

@aseering
Copy link
Contributor

aseering commented Apr 6, 2017

It kinda sounds to me like what you're asking for is Docker :-) Docker for Windows works with WSL today. Native Docker within WSL is tracked by #85 .

@Nox-404
Copy link
Author

Nox-404 commented Apr 6, 2017

Something like that :) I'll close this issue, but the ability to have multiple instances could still be useful if they decide to add another subsystem for android or for any other OS

@Nox-404 Nox-404 closed this as completed Apr 6, 2017
@TomasHubelbauer
Copy link

I am also interested in this. And now we have the ability to run multiple distributions side-by-side.

I am not sure if I understand what you meant in your comment @aseering, but when it comes to conflicting ports, I experimented with running openSuse Leap 42 and Ubuntu side-by-side. I ran python -m SimpleHTTPServer from both and then tried accessing localhost:8000. As long as the first-ran openSuse Leap 42 Python server was running, it was the one receiving the traffic. The Ubuntu Python server saw no traffic even though it was running at the same time, on the same port. Then I killed the openSuse Leap 42 Python server without touching the Ubuntu Python server (it was running the whole time and I didn't restart it, just let it run) and when accessing localhost:8000 again, the Ubuntu Python server started receiving the traffic. I think this behavior is just fine.

My use case for the ability to run multiple instances of one distribution is setting up shortcuts for pre-setup environments for different things. It's true that Docker can give me this as well, but I have Windows 10 Home machines where I can use WSL but not Docker (and Docker Toolbox is a joke), so I don't think having an alternative in multiple instances of a single distribution would hurt. If I could use wslconfig.exe to name the instances to distinguish them, that'd be neat.

My 2 cents anyway. :-)

@therealkenc
Copy link
Collaborator

therealkenc commented Jan 18, 2018

Possible right now (circa 16273 and probably earlier) for the motivated. I did a PoC back in July.

As long as the first-ran openSuse Leap 42 Python server was running, it was the one receiving the traffic.

That's only because #384 wasn't really fixed just stubbed (message). You are seeing the same thing as the guy in #2664, and @aseering is fundamentally correct. We need more networking bits (too lazy to look up an issue ref) and CLONE_NEWNET. We could use some other missing bits like mount(2) "lxfs" too. That said, there is nothing wrong with using different ports in different instances, if it fits people's particular use case.

so I don't think having an alternative in multiple instances of a single distribution would hurt. If I could use wslconfig.exe to name the instances to distinguish them, that'd be neat.

Yes that is the Right™ way to do this (at least in spirit if not the detail). I have been meaning to do something like this for six months, but keep wasting time playing with filesystem related stuff instead (and not even spending significant time at that). Part of the demotivator too is that I suspect if I make a run at it, the effort will end up duplicative of stuff already in the works.

So sit tight. You'll probably get something along the lines of what you want eventually. That is speculation though, natch; I do not know the team's priorities. Also bear in mind what you are really asking for is a death march to Docker. No one said you have to like Docker.

@aseering
Copy link
Contributor

Hm... So, the problem here is, there is only one localhost, and only one port 8000 on localhost. This is hardcoded as part of the IP standard.

WSL could have a separate localhost within each Linux environment. But then you would also have to have a separate localhost for Windows, and localhost:8000 in Windows wouldn't connect to either Linux process. That would be less convenient for simple Web-development use cases, for example. If that's what you want, Docker really is the right tool for the job right now in my opinion; you could pay to upgrade to a fancier Windows version or you could lobby the Docker community to ship (for example) an xhyve-based version for Win10 Home users, like they do for Mac users. (WSL could also solve this problem as you suggest, it's certainly technically possible; someone on the WSL team should reply about it.)

Alternatively, you could assign multiple loopback IP addresses to your system. For example, add 127.0.1.1 and 127.0.1.2 to the Windows loopback interface. I don't know how to do this on Windows, and I'm unfortunateoy not in front of my Windows box right now, but I'm sure there's a way? Then have one Linux process listen on 127.0.1.1 and the other listen on 127.0.1.2. Then Windows can connect to them on those separate IP addresses; they can also connect to each other. Unfortunately, there's non automation for anything like this right now, that I know of.

@TomasHubelbauer
Copy link

@therealkenc I don't know enough about anything to understand your PoC and how to get there, but I am happy to see this is possible in principle and will hope to see it achievable in a way I can use (like wslconfig.exe naming) one day.

Regarding networking and port collisions there may be a better way to do that, but the current behavior seems just fine to me. Offloading the work of ensuring no reuse of ports across the instances to the user is fair game. Having two instances of say Ubuntu just for the price of making sure the ports are not reused? That's a deal right there. So yeah, I don't really consider the current behavior a problem, although I don't know enough to judge whether it can be improved or not.

@therealkenc
Copy link
Collaborator

WSL could have a separate localhost within each Linux environment.

That's CLONE_NEWNET.

Alternatively, you could assign multiple loopback IP addresses to your system. For example, add 127.0.1.1 and 127.0.1.2 to the Windows loopback interface.

That's the extra networking bits missing.

I don't know how to do this on Windows, and I'm unfortunateoy not in front of my Windows box right now, but I'm sure there's a way?

Sure absolutely. Just add it in Device Manager. I take for granted there's some crazy PS way to do it too.

Docker really is the right tool for the job right now in my opinion

Pretty much. The ask is for a better UX.

@TomasHubelbauer
Copy link

For anyone who comes to this issue from Google, I found this Getting Crazy with Windows Subsystem for Linux article which seems to achieve exactly what I wanted to get. I am going to update this comment once I was able to confirm it still works, but it looks very very promising.

@jhoelzel
Copy link

jhoelzel commented Mar 3, 2018

I think this is a good idea! i have been spawning wsl as "integrated terminal" in Vs Code and it works great. But i have multiple different platforms to develop for, so in the end different containers for different things would be nice. but i know its whining on the highest level :D

To be fair, the Main requirement would not be to have them running in parralel (addressing the only one localhost issue, which btw could be solved with hostnames for your instances in your hostconf), but rather have multiple "subystems" which i can then seperatly launch.

@pentatonicfunk
Copy link

so @TomasHubelbauer how was the experiment going ? i see it as promising too 😃

@TomasHubelbauer
Copy link

@pentatonicfunk I got myself so immersed in LxRunOffline I forgot to reply! It's good, I recommend you try it.

I still wish this was native to WSL, but LxRunOffline is really, really good. Currently I miss three things from it: I wish it was able to create taskbar shortcuts with the correct icon, I wish it was able to create users with passwords by default like WSL and I wish it ran in the same terminal. With these two features it would be possible to have an exact copy of Ubuntu, OpenSure or what have you, indistinguishable from the original creatible thru WSL.

On top of it, @DDoSolitary updates the project regularly and is clearly very capable, so while experimental, the project is very stable.

@pentatonicfunk
Copy link

@TomasHubelbauer well you are too late, i already setup 2 additional instances of ubuntu on WSL. Indeed @DDoSolitary did a great job. As for taskbar icon, i dont see any problem i can change it Via Properties -> Change Icon
Alt text

@TomasHubelbauer
Copy link

@pentatonicfunk Yep, I meant that more as in I'd like it to be a one-click solution where you click to get a new Ubuntu instance and you have it. But I am sure I can script this, I considered doing that, but I found it impossible to locate the original Ubuntu icon file, I don't remember why, but it was either because the ICO file was in an inaccessible directory or it came from an EXE file which was inaccessible to me. Anyway this is a total digression. :-)

@bbulkow
Copy link

bbulkow commented May 6, 2018

Hey. With all the comments about "what about networking ports", really, I'm not bothered by that.

I know WSL is just a shell. It's not a container, it's not a VM. I don't want it to be.

I do want multiple environments ( with the same network ) just to have different versions of python, different versions of Java, different versions of node.... I can keep track of ports and make sure ports don't get confused.

If I have two shell windows, I know they're running the same set of ports. If I have two shell windows of different distributions.... same ports, still useful.

Hope that helps understand why I want this feature even without virtualized networks.

@b-hayes
Copy link

b-hayes commented Nov 2, 2020

We use docker containers for all the projects and they all use different ports and can run together however, they sometimes have some reliance on a localally installed tool to setup and manage the dev environment or to run webpac server, compile/run some android or iso app etc and even tho the supporitng servies use different ports they can not use the same version of the locally installed tools to compile and run. So you can not work on the two projects at the same time without stoppping one changing tools and then working on the other.

Altho it does seem that WSLv2 is might have solved this problem already but I havnt tried it yet. If anyone has can they comment on their experience?

@Biswa96
Copy link

Biswa96 commented Nov 2, 2020

@b-hayes This StackOverflow thread may help https://stackoverflow.com/q/51584765/8928481

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

No branches or pull requests

9 participants