211 points · by cachehit · 5y ago · 169 comments
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?).
Not sure about Parallels.
In Parallels it's on by default but you need to allocate a lot of RAM to the VM: https://kb.parallels.com/en/125105#section6
Pinned tracking thread:
https://forum.parallels.com/threads/big-sur-installation.351...
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.
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'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.
https://code.visualstudio.com/docs/remote/remote-overview
Virtualized Linux on x86 AND being able to run VSCode on your Mac for great fonts, WiFi, screen etc without having to fuss with drivers.
Of course ssh and tmux also work well for this purpose.
People are advocating remote development heavily, so there must be some *huge* benefit that I don't understand. So much so that people are willing to give up amazing features of an IDE. To get VSCode to a usable state requires 16 third-party plugins, and you're left with about 1/3 of JetBrains functionality, in which the features aren't quite as good. YMMV I guess?
Mixed scale DPI screens are not a problem if you use Wayland, which is basically the default now.
Font rendering though? YMMV.
Docker on Mac has a lot of IO overhead. This is mentioned in the article:
> The way I made it work is by having a full “dev environment” running virtually. 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.
If you just want improved performance with bind mounts instead, you can use :cached or :delegated flags.
I think Fusion comes with a driver for Docker
If so, why do you need rust compiler in the first place? May be you don't? May be it's wrong compiler?
It worked well, except that I occasionally want to run a container within my dev-environment. Running a container inside a container is possible, but not easy.
I settled on running a Vagrant Libvirt VM. I do not know what the performance impact is- but I have not noticed either my laptop or the VM being slow.
Do you know of a set of settings or tips to follow for making containers as safe as a VM?
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)
Many devs just blindly install things from npm, copy random snippets from GitHub gists, execute remote shell scripts via curl that they just copy and paste into the terminal because they read it in some blog post, and on and on.
Anyway, just my worthless < 2 cents.
1: https://docs.microsoft.com/en-us/windows/security/threat-pro...
Additionally, VMs might be a great help to complicated debugging. You can crash a VM without taking down your desktop. I'm not sure about things like kernel debugging, but it might be easier in a VM.
You can use your windows or Mac laptop with visual studio code to do web development. ng serve works as if you ran it from your laptop.
The biggest drawback I can think of is if you ever needed to leave the house. Thankfully, I have no life so I don't have this problem.
Add ZeroTier to the equation and as long as you have Internet connection when you're outside the house you'll probably not even notice it.
I just use ssh. SSH to a VPS and map 22 to a port on the VPS.
I have a really small VPS for this.
Does it solve the security problem by preventing access to the majority of your home directory?
Or solve it by only allowing you to install vetted libraries?
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.
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.
I ended up going with a VM, as it still allows (IIRC) the thin client to be thinner. There's definitely bits of containers I miss, like I'm back to keeping notes in a markdown file for commands that would be added to a Dockerfile, but I'm also not having to do weird things to get something like my shell history to persist.
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...
> we have WSL 2 on Windows which is what I use
My new work laptop runs Windows, so I'm interested in WSL2. I gather that it has good integration with Windows (eg you can type notepad and notepad will open)- which is convenient but removes any security boundary.
> Does Parallels let you seamlessly run floating windows across your VM and macOS?
I don't use Parallels, or Mac. But I believe so- they call it Coherence https://kb.parallels.com/4670
I agree that not everything is as convenient. My papercuts were not being able to type `code .` to make a new VSCode window. And not being able to use the new tab shortcut in my terminal to make a new tab in the current directory.
I've made a little project to solve both those issues for me https://github.com/ccouzens/ssh-nicety It works, but is fairly bespoke to my setup. It uses Unix Domain sockets (which probably excludes Windows). The only new terminal it can launch atm is gnome-terminal.
If you decide to use it, I have another more up to date video with my whole WSL 2 / Docker / all the tools I use / etc. set up at: https://nickjanetakis.com/blog/a-linux-dev-environment-on-wi...
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
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.
Remotes can be anything: I have a KVM host at home (that I remote to from my Mac for Docker dev) and plenty of Azure VMs.
I use blink for the terminal app and connect using mosh instead of ssh. I found that mosh handles the connection (reconnection) way better since iPadOS is pretty aggressive in killing the terminal app if I switch to a different app. I use also tmux on the server and just detach it when I'm done in case I want to work on it on my laptop or desktop. Overall works great, my only issue is that the 10.9" iPad screen is a _little_ bit too small for my liking so I don't do work like this that much. If I had the 12.9" iPad it would probably be something I use daily.
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.
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.
When running remote VMs I usually run them on my ESXi box in the basement and VPN back home when traveling. This is especially nice when a project needs more resources than whatever device I’m working on has to offer. But beside this very specific use case I haven’t personally found any advantage of this setup.
> 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?
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'.
Have built an Ubuntu 18 environment running through UTM (https://getutm.app/ - running qemu). Took a bit of tomfoolery where I had to install using a console only display and then flick back to full graphics to get the machine to boot.
Use port forwarding to talk to the machine - haven’t figured out a way to do bridge mode like I can with virtual box.
We’ve got a bunch of crazy dependencies that I’m in the process of rebuilding. Most seem to be ok. There’s a third party one we’re a bit trapped with but we’re running that emulated x86 within the vm. You can also use docker the same way within the vm.
Performance wise the arm vm is blazing fast. Seems to be about 20x faster than an x86 vm on my old MacBook 2015. It’s about 2x the speed of an 8 core graviton2. When running emulated x86 code, the speed drops to about 1/4 the speed of my old 2015 MacBook. Not ideal but in our case we’ve only got a single non arm dependency and it’s not used often, so it works for us.
It’s a bit of a leap, and if you have more crazy binary dependencies like we do, you will have do to a little work to get things running.
Having said that, the machine itself is _amazing_. It’s a real joy to be on a machine with this level of responsiveness.
As an alternative could you use React Native and borrow an Apple product during compile day?
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.
All the Docker pseudo-ports just run a Linux VM on the host OS and set up Docker inside it, for you.
Docker images are not portable, they run on Linux or on Windows, but they can never run on both.
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.
What exactly are you guys running that causes it to be "unbearable"?
Most of the performance issues with Docker on Mac happen in setups where source code or other files are volume mounted from the Mac filesystem into the container filesystem.
Docker on Mac can be dog slow. This is appealing to me.
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 -
Host <hostname>
HostName <Hostname IP>
User <User>
IdentityFile <Identity File Path>
LocalForward 127.0.0.1:8000 127.0.0.1:8000
LocalForward 127.0.0.1:7000 127.0.0.1:7000
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.
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/
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?
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.
Thanks for the tip, that's good to know. I'm running RC2 and haven't come across any issues like that, although I don't run my Docker containers in 'privileged' mode when using Vagrant.
Any idea if Parallels would work better on the M1?
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.
Then the author could access the files via Finder.
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).
Yes. Except on Windows it is easy to access WSL files.
Unsurprisingly, WSL2 does something similar (it uses the 9p protocol instead of SMB though).
(a) HN has people who like new technology.
(b) This particular new technology is also very good.
What's difficult to understand about it?
People have been tinkering with WSL and Linux to have all kinds of things working "in random ways that arent supported yet etc", M1 is not that different...
I want to run multiple VMs at the same time and my current quad core iMac struggles. So I was thinking of getting a beefy Lenovo Workstation to use as a dev environment and use the VScode remote ssh thing. But in that case I don't really to upgrade my iMac.
I've been using Linux development laptops for the past decade and have had all of these benefits!