Live data from Hacker News

Developing inside a virtual machine

blog.disintegrator.dev

21–30 of 147 posts

Re: Developing inside a virtual machine

#21

is there a way to forward usb/serial ports from my local machine to the dev container? maintaining consistent firmware development environments using containers is a great idea, and current solutions involving proxying the compiled binary work well for flashing quickly, but switching back and forth between UART and Serial Debug is always more convenient when the IDE can handle it all

VMWare has an excellent implementation of this which can selectively connect devices to the guest, and it properly remembers the action for each device you connect to your computer.

Re: Developing inside a virtual machine

#22
post #5

I do something similar but using WSL on Windows. But something I really, really hate is dealing with special certificate handling required to pass the corporate Zscaler proxy. I think it works somewhat transparent on the Windows host, but repeating the setup in every VM is such a pain.

Given how much you hate it, any chance you documented how you did it?

No not really. The employer has some documentation, it is not complete but is starting point when issues pop up. For example, a JDK neeed to have special certificates installed if Java tries to talk SSL. And when you juggle with different JDKs for different Java versions it becomes a nightmare. The best you can do is to try not to touch anything when it eventually works but eventually something unforeseen breaks it anyways.

Re: Developing inside a virtual machine

#23
post #12

is there a way to forward usb/serial ports from my local machine to the dev container? maintaining consistent firmware development environments using containers is a great idea, and current solutions involving proxying the compiled binary work well for flashing quickly, but switching back and forth between UART and Serial Debug is always more convenient when the IDE can handle it all

Not sure what your host OS is, if Linux, QEMU can pass usb devices to the guest. Otherwise you could pipe serial over TCP

interesting, specifically I'm on a host Mac and trying to use the ESP IDF dev containers in VSCode (https://docs.espressif.com/projects/vscode-esp-idf-extension...)

will try again with sockets/TCP, thought i hit a roadblock after reading https://github.com/docker/for-mac/issues/5263#issuecomment-7...

Re: Developing inside a virtual machine

#24

is there a way to forward usb/serial ports from my local machine to the dev container? maintaining consistent firmware development environments using containers is a great idea, and current solutions involving proxying the compiled binary work well for flashing quickly, but switching back and forth between UART and Serial Debug is always more convenient when the IDE can handle it all

You mean forwarding to VSCode dev container?

If you are using Docker Engine directly on Linux, you can forward a device to a container via docker-compose `devices` setting.

If you are using Docker Desktop (or similar), there is no native way. However, there are ways to share USB devices via network (USB/IP is an open source implementation of this), in which case you setup server on host device (can be macOS/Windows/Linux), and then run a client software inside a container.

Re: Developing inside a virtual machine

#26

You can use pbcopy/pbpaste in a Linux VM on Mac by making a shell script wrapper in the VM that calls “ssh mac-host pb{copy|paste}” - that is, basically ssh back from the guest to the host to use its clipboard. It’s seamless and fast since it’s basically a local network connection. My specific setup is that I use an authorized_keys entry on the host that restricts the guest to running a specific command, which limits…

Brilliant tip! I’m going to give it a shot tomorrow and update the post (with attribution).

Re: Developing inside a virtual machine

#27
post #11

Why does the author need a “remote ssh” plugin in their VSCode? I usually develop inside a VM as well, with my IDE running in the host… but what I do is to mount a shared directory for the code between the host and the VM. Works pretty fast. Don’t understand the need for Tailscale either. When I’m running services or dbs inside the VM, I can easily access them if needed from the host (either by IP or by the hostname…

As others have mentioned, I’ve not had great performance with shared folders and the SSH extension in VS Code is so damn good. Over time, you forget it’s even running because you open recent projects and it remembers which were local (on host) and which are on the guest and SSH’s in automatically.

I could probably revise my use of Tailscale. My vague recollection is that I had networking issues when my laptop woke up and Tailscale didn’t have the same issues. Probably a debugging skill issue on my part.

Re: Developing inside a virtual machine

#28
Windows 11 and WSL manages this well . For those developing linux apps & containers using VS Code, you'll find the Windows 11 experience to be very good. You can code against WSL which offers the more popular distros, or use HyperV to run your own custom VMs.

Re: Developing inside a virtual machine

#29
post #8

Earlier quoted context omitted.

I used to do that, but now that all of our microservices are dockerized every microservice has its own docker container Vscode supports remote containers, so everyone in the org just develops INSIDE a replica of the prod container All containers run remotely on enormous machines with 800+ GB of RAM and 8+ GPUs It’s trivial to share environments now because you just open the project and the dev container starts up and…

What do devs who don't use VSCode do to work in this environment?

We only have one who hasn't made the switch, he works in vim inside the docker container.

I dont actually mind what development environments our devs use, as long as your productivity is up and you get the job done and you are happy. You can use a magnetised needle for all I care, whatever makes you the best version of you.

Re: Developing inside a virtual machine

#30
post #5

I do something similar but using WSL on Windows. But something I really, really hate is dealing with special certificate handling required to pass the corporate Zscaler proxy. I think it works somewhat transparent on the Windows host, but repeating the setup in every VM is such a pain.

Heh, my employer is rolling out Zscaler this year. The limited trial a few months ago was hell for folks using WSL primarily, with Docker images adding an additional layer of pain. The people in the trial got very little done until it was decided to pause it, and I do not have high hopes for when it’s tried again. It strikes me as basically running malware in the name of security.

[dead]
Post reply on HN