Everyone is talking about running a separate Linux dev environment, but I'd actually love to run a separate macOS dev environment in a clean way (i.e. without messing with partitions for dualboot, especially on the M1).
I get my stuff from Homebrew, just Rails + MySQL, no Docker, no fancy stuff. I'd love to have a fast macOS VM to run software I don't trust like Zoom or Skype and a second one to run my work projects, so they don't spill over my personal stuff, but AFAIK the virtualization story is still pretty incomplete on the M1 (or is there a way to run an arm64 macOS VM without a gigantic performance hit?).
If I recall, VMWare Fusion and Parallels can run macOS VMs with little or no speed hit, under Big Sur. Big Sur added GPU virtualization support so VMs aren’t slow, previous macOS versions lacked this.
It’s not smooth enough for me to consider regularly using for most work but you can setup macOS VMs from parallels/fusion inside of macOS since apple allows it on their hardware (...or a hackintosh).
It’s not as easy to get working compared to a windows vm because I believe it uses the OS recovery image but it’s not that hard to setup and works well. I’ve used it in the past to test my dotfiles setup on a perfectly clean install.
I still haven't tried it, but what if you downloaded the iOS apps on the M1? Wouldn't it be more containerized if you ran those apps from the phone "emulator"
I think running your dev environment in a VM is the future on all platforms.
As developers we trust so many different libraries. And it is important that they are safe when used in production code.
But we shouldn't have to worry about accidentally installing a library which uploads our emails or our browser data. By working from a VM we can prevent that.
The worst a malicious library can do from a VM is upload our SSH keys or source code (which is still bad).
I hear what you're saying, but the last time I worked through a linux VM on my mac laptop, everything got much slower. Our nodejs service took 2-3x longer to start up or to build. I think the issue was filesystem overhead for some reason. The future might involve working from a VM when we have CPU cycles to spare. But right now I need every iota of speed my computer has for my rust compiler.
I'd much rather we solve the security problems using better local sandboxing for software, like how it works on our phones. That would help end users as well, and it would stop crypto ransomware and all sorts of other attacks. Or alternatively, run my dev tools from a solaris zone or a freebsd jail or something, both of which have no performance impact.
A properly secured unprivileged Linux container is not particularly worse than VM from a security point of view, but its impact on performance is very minimal. The drawback is that one cannot use Mac or Windows as a host, but as long as one is OK with running Linux on machine and accessing, say, Windows occasionally via VM, this is a very nice setup.
Actually I think VMs for dev are evil. I hope it's a stop gap measure until tooling like nix catches up enough. Running an entire seperate OS just for development is completely bonkers to me.
I've been reluctant to contribute to nodejs (e.g. electron) projects for some time, because I just don't want to run npm on a computer with any kind of remotely private data.
Lately there were just too many itches to scratch, so I went for a VM replicating my normal setup (dotfiles etc.), and I just use x2go, locally. Quick and dirty setup which is good enough when used infrequently.
> I think running your dev environment in a VM is the future on all platforms.
We probably have a long ways to go before we get there and it does come with its own sets of challenges and usability quirks even if the technical implementation is good.
For example, 8 years ago I used to run Windows 7 with xubuntu running in a graphical vmware VM using Unity mode[0]. Basically a way to seamlessly run graphical Linux apps in Windows. Each GUI app you launched from the Linux VM would have its own floating window that you could move around like any other Windows window. As an aside, this feature has been removed from vmware for years now when it comes to Linux guests.
It worked well enough for then, and I spent 99% of my time in that VM (browser, code editor, everything) and I only used Windows for recording / editing videos and playing games to avoid having to dual boot.
But even with vmware's really good disk performance there were performance issues at times, you're also splitting your memory up between your main system and your VM, it's not that efficient. Then there's little quirks like your main OS not really fully being able to integrate with files and apps from the VM, so you have to do hacky things to get apps to launch from a taskbar, search doesn't work because your stuff is in a VM, etc.. Plus you always feel like you're split between 2 worlds, the main OS and the VM. It doesn't feel really nice and cohesive.
To a lesser extent nowadays we have WSL 2 on Windows which is what I use. It solves a lot of the VM problems from above and running an X-server lets you run graphical apps very well, but you still feel like you're running 2 operating systems and the user experience suffers because you don't feel like you're running 1 streamlined OS.
A prime example is having to put all of your files in WSL 2's file system to get good performance but having certain types of files there is an inconvenience or you may not want to do it because it doesn't make sense to put 100GB of storage files on your SSD. That happened to me because I have a podcast site which is mostly code, except for a ton of raw wav file recordings + mp3s. Instead of just having a git ignored directory in my project, I had to create a 2nd directory outside of WSL to store these files. There's many other examples like this too.
I don't know what the Mac story is like, but I would imagine at minimum you're dealing with files being split into 2 worlds and will experience the unfriendly split OS feeling overall. Does Parallels let you seamlessly run floating windows across your VM and macOS?
I agree. We need something like Firecracker and quick boot times and something like Bottlerocket (immutable os) as the host. That woukd help my workflows very much.
Personally pushing the edit, compile, run cycle time as low as possible has always been the reason I have stayed away from dev VMs. For 99% of computer uses a VM is fast enough but unfortunately for many programming tasks, it is not.
I’ve been doing this with minor variations for a while now (from my iPad, from my Mac, my netbook, etc.) towards VMs in various places (your favorite flavor of cloud, my favorite closet, etc.).
It has become remarkably seamless and trivial to switch any of the local/remote pairs over time, and definitely cleaner than managing various app runtimes on my local machines (I have cloud-config templates to bootstrap fresh Go, Java and Node boxes as required).
edit: forgot to mention I'm posting this from another of those combos, a Windows VM I remote to from my iPad whenever I need a desktop browser
Can you explain more about your setup, in particular the iPad part? What apps are you running on your iPad to facilitate dev work? And when talking remote instances, do you mean something like a droplet/vps?
My dream is to code web apps from my iPad from the couch/bed as I sit at a big desk and monitor all day for work and I just want to chill in the evenings on something smaller and more comfortable.
To give an additional data point for people who are interested how a setup like this performs for daily use:
I am currently running Parallels Tech Preview on the MacBook Air M1 and primarily use PyCharm (remote interpreter and deployment to the VM). The whole thing works better than expected considering it’s still a preview release. Battery lasts around 12 hours, sometimes an hour or so more depending on what else I run.
I am currently working on a Django app. When saving while the debug server is running I can command tab to my REST client and make an API request and the change was already deployed and the server restarted. Despite dealing with a VM the whole thing is just fast.
If you don’t absolutely need a local VM I’ve found it much nicer to have a beefy ec2 instance be the Linux vm that you connect to in order to work in Linux on x86.
Recently I’ve been doing this with VSCode which has a remote dev mode that works amazingly well. Before that I was just using ssh and tmux/screen which, as we know, also works and has worked for decades.
> I had two requirements for developing that I wanted to achieve: macOS UI, Linux-based dev environment
What exactly is meant by a linux-based dev environment? Seems like the idea is to run the whole dev environment is in a virtual disk in a VM. I'm puzzled, but ok. It then goes on to set up Ubuntu Server in this VM, which is then used to host the dev environment.
Wouldn't simple running a docker instance both be less cumbersome, far more resource efficient, and quick to iterate, than literally installing an OS on a virtual disk?
---
To summarize, unless I missed something, this looks to explain that it is possible to run a VM on a MacOS. Add "M1" and it's the top post on hacker news? What's going on here?
That this is 'M1' is relevant for me personally, as my current Mac is dead old, I 'need' a Mac for iOS development, the Intel ones are a dead end and seem to run hot often, and it is unclear if all my dev needs will be met by the M1.
Any piece of information that untangles this mess is helpful to me. Of course this may not be the same for others, but it could be 'what's going on here'.
> Wouldn't simple running a docker instance both be less cumbersome, far more resource efficient, and quick to iterate, than literally installing an OS on a virtual disk?
On Mac, docker works by installing a VM- so the two aren't so different.
I (not the author) prefer using a VM as a development environment, because at some point I'll want to run a container and nested containers are tedious.
> Seems like the idea is to run the whole dev environment is in a virtual disk in a VM
Pretty much.
I had bad experiences running Docker directly on MacOS. The IO latency was unbearable. I know they are working hard on it so maybe it's better now, but this setup works well for me.
I've been doing something like this for about 3 months with very good success. This is also pretty much the only "complete" solution I could come up with that doesn't involve duct taping 3-4 different things and keeping them all in my head.
A simpler solution I had - One linux vm, SSH connection plugin in VSCode and a simple 4 line SSH config file (~/.ssh/config) does magic.
The LocalForwards are key in setting up any tunnels I need working locally - you can tunnel as many ports as you need.
I use the terminal inside VSCode - which means I can manage docker(-compose), microk8s, etc and anything I spin up, I'll just be able to access from my local host during testing.
I am looking for a quiet and fast machine for development. I've been trying to find a reasonable AMD laptop but all are out of stock and I think these will still have fans buzzing under heavier load. I personally hate Apple practices and I never clicked with macOS (was forced to work with it for many years), but if I could install Linux on M1 it would be hard to swallow, but I may consider using it. My Intel laptop has fans buzzing now even when it is idle. It drives me crazy.
Do you absolutely have to have a laptop? I realized years ago that I spend 99% of my time in a single place and have since built custom desktop systems for my primary development machine. They are faster than any laptop I ever owned, quieter and much easier to live with. And because I can put together a system to my own specifications I can end up with something that works perfectly with Linux. I haven't bought a Mac in years and even with their new ARM hardware I don't see enough of a benefit to go back.
I'm in a similar situation. I want a new x86 laptop for development, but it's not super urgent.
Some laptop built around the new Ryzen 9 5900HS cpu [0] seemed like an obvious choice. But although it seems like AMD has released it, I'm having trouble finding any actual laptops that have it as an option. Maybe I'm just not looking hard enough?
I got an HP OMEN 15 for $1200 and added some memory - 32gb with 8 cores, 16 threads and a nice IPS 144hz screen. I run VirtualBox Ubuntu 20.04 VMs with docker inside them and connect with VS Code SSH - and I have no performance complaints.
Vagrant works great on Macs with M1, the issue is finding a compatible 'provider' (VirtualBox, VMWare etc).
For my personal projects I've been able to switch from using VirtualBox to Docker as a Vagrant provider, and it works well enough for what I need it to do.
The article author uses VSCode remote support to work with VM. This is not ideal from a security point of view. VSCode is huge, typically uses a lot extensions and all that has access to all local files and ssh keys. So for this reason I run VSCode inside a VM or a container with VNC server to provide X session. This works OK without GPU even on 4K screen while providing much better isolation.
Ah, echoes of the "why use this new Dropbox thing when I can use FTP, SVN, and some FTPFS" attitude. You're right, what you've suggested works.
It would still result with VS Code running more on your client than it would when using VS Code Remote.
Port tunnelling, while totally possible with an SSH command in a new terminal, is something VS Code just sets up automatically (and makes it easy to add your own).
> That means that I check out repositories on the virtual disk and run everything from there. This has the slight inconvenience that I can’t easily access those files with Finder, but the upside is that there is no noticeable IO latency issues like when running Docker for Mac.
Yes. Except on Windows it is easy to access WSL files.
I dont understand this HN infatuation with apples new chip laptops. Ppl are doing everything under the sun to make it work in random ways that arent supported yet etc.
[+] [-] Toutouxc|4 years ago|reply
I get my stuff from Homebrew, just Rails + MySQL, no Docker, no fancy stuff. I'd love to have a fast macOS VM to run software I don't trust like Zoom or Skype and a second one to run my work projects, so they don't spill over my personal stuff, but AFAIK the virtualization story is still pretty incomplete on the M1 (or is there a way to run an arm64 macOS VM without a gigantic performance hit?).
[+] [-] kitsunesoba|4 years ago|reply
[+] [-] upbeat_general|4 years ago|reply
It’s not as easy to get working compared to a windows vm because I believe it uses the OS recovery image but it’s not that hard to setup and works well. I’ve used it in the past to test my dotfiles setup on a perfectly clean install.
[+] [-] balloneij|4 years ago|reply
[+] [-] rovr138|4 years ago|reply
[+] [-] mixmastamyk|4 years ago|reply
[+] [-] ccouzens|4 years ago|reply
As developers we trust so many different libraries. And it is important that they are safe when used in production code.
But we shouldn't have to worry about accidentally installing a library which uploads our emails or our browser data. By working from a VM we can prevent that.
The worst a malicious library can do from a VM is upload our SSH keys or source code (which is still bad).
[+] [-] josephg|4 years ago|reply
I'd much rather we solve the security problems using better local sandboxing for software, like how it works on our phones. That would help end users as well, and it would stop crypto ransomware and all sorts of other attacks. Or alternatively, run my dev tools from a solaris zone or a freebsd jail or something, both of which have no performance impact.
[+] [-] _0w8t|4 years ago|reply
[+] [-] the_duke|4 years ago|reply
A better solution would be a desktop OS with proper application sandboxing. Mac OS is taking many steps in that direction.
Linux - as usual - has a multitude of solutions, all of them problematic. (AppArmor, SeLinux, Firejail, Snap, Flatpak)
[+] [-] rowanG077|4 years ago|reply
[+] [-] hiq|4 years ago|reply
I've been reluctant to contribute to nodejs (e.g. electron) projects for some time, because I just don't want to run npm on a computer with any kind of remotely private data.
Lately there were just too many itches to scratch, so I went for a VM replicating my normal setup (dotfiles etc.), and I just use x2go, locally. Quick and dirty setup which is good enough when used infrequently.
My ideal setup would probably be closer to https://blog.jessfraz.com/post/docker-containers-on-the-desk..., but it's more setup than I could be bothered with at the time. Maybe one day.
[+] [-] m463|4 years ago|reply
Are containers a hack that will go away as VMs become lightweight or will containers replace VMs?
I run proxmox, and when I first set things up I used VMs, but over time I moved most server kinds of things to containers.
EDIT: docker is a special thing - creating an entire environment from one Dockerfile is pretty powerful.
[+] [-] nickjj|4 years ago|reply
We probably have a long ways to go before we get there and it does come with its own sets of challenges and usability quirks even if the technical implementation is good.
For example, 8 years ago I used to run Windows 7 with xubuntu running in a graphical vmware VM using Unity mode[0]. Basically a way to seamlessly run graphical Linux apps in Windows. Each GUI app you launched from the Linux VM would have its own floating window that you could move around like any other Windows window. As an aside, this feature has been removed from vmware for years now when it comes to Linux guests.
It worked well enough for then, and I spent 99% of my time in that VM (browser, code editor, everything) and I only used Windows for recording / editing videos and playing games to avoid having to dual boot.
But even with vmware's really good disk performance there were performance issues at times, you're also splitting your memory up between your main system and your VM, it's not that efficient. Then there's little quirks like your main OS not really fully being able to integrate with files and apps from the VM, so you have to do hacky things to get apps to launch from a taskbar, search doesn't work because your stuff is in a VM, etc.. Plus you always feel like you're split between 2 worlds, the main OS and the VM. It doesn't feel really nice and cohesive.
To a lesser extent nowadays we have WSL 2 on Windows which is what I use. It solves a lot of the VM problems from above and running an X-server lets you run graphical apps very well, but you still feel like you're running 2 operating systems and the user experience suffers because you don't feel like you're running 1 streamlined OS.
A prime example is having to put all of your files in WSL 2's file system to get good performance but having certain types of files there is an inconvenience or you may not want to do it because it doesn't make sense to put 100GB of storage files on your SSD. That happened to me because I have a podcast site which is mostly code, except for a ton of raw wav file recordings + mp3s. Instead of just having a git ignored directory in my project, I had to create a 2nd directory outside of WSL to store these files. There's many other examples like this too.
I don't know what the Mac story is like, but I would imagine at minimum you're dealing with files being split into 2 worlds and will experience the unfriendly split OS feeling overall. Does Parallels let you seamlessly run floating windows across your VM and macOS?
[0]: Here's a really old video of that set up https://nickjanetakis.com/blog/create-an-awesome-linux-devel...
[+] [-] StreamBright|4 years ago|reply
[+] [-] ttiurani|4 years ago|reply
[+] [-] rcarmo|4 years ago|reply
It has become remarkably seamless and trivial to switch any of the local/remote pairs over time, and definitely cleaner than managing various app runtimes on my local machines (I have cloud-config templates to bootstrap fresh Go, Java and Node boxes as required).
edit: forgot to mention I'm posting this from another of those combos, a Windows VM I remote to from my iPad whenever I need a desktop browser
[+] [-] dchuk|4 years ago|reply
My dream is to code web apps from my iPad from the couch/bed as I sit at a big desk and monitor all day for work and I just want to chill in the evenings on something smaller and more comfortable.
[+] [-] fallenhitokiri|4 years ago|reply
I am currently running Parallels Tech Preview on the MacBook Air M1 and primarily use PyCharm (remote interpreter and deployment to the VM). The whole thing works better than expected considering it’s still a preview release. Battery lasts around 12 hours, sometimes an hour or so more depending on what else I run.
I am currently working on a Django app. When saving while the debug server is running I can command tab to my REST client and make an API request and the change was already deployed and the server restarted. Despite dealing with a VM the whole thing is just fast.
[+] [-] tbrock|4 years ago|reply
Recently I’ve been doing this with VSCode which has a remote dev mode that works amazingly well. Before that I was just using ssh and tmux/screen which, as we know, also works and has worked for decades.
[+] [-] okamiueru|4 years ago|reply
> I had two requirements for developing that I wanted to achieve: macOS UI, Linux-based dev environment
What exactly is meant by a linux-based dev environment? Seems like the idea is to run the whole dev environment is in a virtual disk in a VM. I'm puzzled, but ok. It then goes on to set up Ubuntu Server in this VM, which is then used to host the dev environment.
Wouldn't simple running a docker instance both be less cumbersome, far more resource efficient, and quick to iterate, than literally installing an OS on a virtual disk?
---
To summarize, unless I missed something, this looks to explain that it is possible to run a VM on a MacOS. Add "M1" and it's the top post on hacker news? What's going on here?
[+] [-] icoder|4 years ago|reply
Any piece of information that untangles this mess is helpful to me. Of course this may not be the same for others, but it could be 'what's going on here'.
[+] [-] ccouzens|4 years ago|reply
On Mac, docker works by installing a VM- so the two aren't so different.
I (not the author) prefer using a VM as a development environment, because at some point I'll want to run a container and nested containers are tedious.
[+] [-] oblio|4 years ago|reply
All the Docker pseudo-ports just run a Linux VM on the host OS and set up Docker inside it, for you.
[+] [-] kristiandupont|4 years ago|reply
Pretty much.
I had bad experiences running Docker directly on MacOS. The IO latency was unbearable. I know they are working hard on it so maybe it's better now, but this setup works well for me.
[+] [-] lawik|4 years ago|reply
Docker on Mac can be dog slow. This is appealing to me.
[+] [-] arvindamirtaa|4 years ago|reply
A simpler solution I had - One linux vm, SSH connection plugin in VSCode and a simple 4 line SSH config file (~/.ssh/config) does magic.
Here's my config file -
The LocalForwards are key in setting up any tunnels I need working locally - you can tunnel as many ports as you need.I use the terminal inside VSCode - which means I can manage docker(-compose), microk8s, etc and anything I spin up, I'll just be able to access from my local host during testing.
[+] [-] varispeed|4 years ago|reply
[+] [-] fanatic2pope|4 years ago|reply
[+] [-] gpanders|4 years ago|reply
[+] [-] CoastalCoder|4 years ago|reply
Some laptop built around the new Ryzen 9 5900HS cpu [0] seemed like an obvious choice. But although it seems like AMD has released it, I'm having trouble finding any actual laptops that have it as an option. Maybe I'm just not looking hard enough?
[0] https://www.amd.com/en/products/apu/amd-ryzen-9-5900hs
UPDATE: Maybe I just needed to wait a little longer: [1]
[1] https://www.ultrabookreview.com/35985-amd-ryzen-9-laptops/
[+] [-] jgalentine007|4 years ago|reply
[+] [-] ansible|4 years ago|reply
1. Low-end Chromebook (good battery life), remote server, VPN.
2. High-end Chromebook (there are a few i3 and i5 models with 8GB RAM), Linux environment.
Are you often in locations where you don't have Internet access?
[+] [-] hopsoft|4 years ago|reply
[+] [-] sdevonoes|4 years ago|reply
[+] [-] tmiller02|4 years ago|reply
For my personal projects I've been able to switch from using VirtualBox to Docker as a Vagrant provider, and it works well enough for what I need it to do.
I created a cookiecutter template for Django projects at https://github.com/tmiller02/cookiecutter-django-react-ansib... that I use for development on my M1 mac using Vagrant + Docker.
[+] [-] lloeki|4 years ago|reply
I'm currently using Docker for Mac but will move to UTM (a.k.a a nice UI atop qemu-hvf) when I have some time at hand.
Vagrant I only used for some other OS VMs (e.g smartos) but the base images are x64 so there's no chance it works well (if ever) on ARM either.
[+] [-] unknown|4 years ago|reply
[deleted]
[+] [-] _0w8t|4 years ago|reply
[+] [-] unknown|4 years ago|reply
[deleted]
[+] [-] ThinkBeat|4 years ago|reply
Then the author could access the files via Finder.
[+] [-] mikewhy|4 years ago|reply
It would still result with VS Code running more on your client than it would when using VS Code Remote.
Port tunnelling, while totally possible with an SSH command in a new terminal, is something VS Code just sets up automatically (and makes it easy to add your own).
[+] [-] sylens|4 years ago|reply
[+] [-] hu3|4 years ago|reply
Yes. Except on Windows it is easy to access WSL files.
[+] [-] xbar|4 years ago|reply
[+] [-] shoulderfake|4 years ago|reply
[+] [-] tlhunter|4 years ago|reply
I've been using Linux development laptops for the past decade and have had all of these benefits!