News for hackers. Stuff that matters.
Re:VSCode, Dev Containers and Docker by onion2k on Thursday January 21, 2021 @10:35AM (#25859929)
Doing any sort of development with Docker on OSX can be painfully slow if you have a lot of files that change frequently. There are a few projects to improve it but they quite aren't there yet. It's my least favourite aspect of modern web work.
Re:VSCode, Dev Containers and Docker by adamkl on Thursday January 21, 2021 @10:57AM (#25860200)
To make it workable I had to just give up on the local host file integration.

I basically used the container like a VM. Configured it with all the tools I normally use (e.g. OhMyZsh, etc) and had it constantly running in the background. I would use VS Code as a front end and work directly inside the container (cloning repos and pushing commits).

It had its quirks but the main benefit was that my local machine was no longer a snowflake. I could easily move to any machine, pull my "development" image, spin up the container and everything was exactly as I liked it.

Re:VSCode, Dev Containers and Docker by IggleSniggle on Thursday January 21, 2021 @11:09AM (#25860370)
What would be the advantage of this setup over a traditional VM where you presumably have more portability of the stateful image?
Re:VSCode, Dev Containers and Docker by treis on Thursday January 21, 2021 @11:36AM (#25860744)
Since they're lighter weight it's easier to run more of them. Think of a place with 7-8 different applications, a few different DBs to support them, redis, elastic search, etc. You can spin up a mirror of your production environment with one command. Theoretically you can do the same with VMs but it will consume a lot more resources.
Re:VSCode, Dev Containers and Docker by nly on Thursday January 21, 2021 @12:09PM (#25861231)
This is only true of Docker on Linux hosts.
Re:VSCode, Dev Containers and Docker by treis on Thursday January 21, 2021 @12:52PM (#25861765)
Even on Windows/Mac you're probably better off running 1 VM and then docker inside of it.
Re:VSCode, Dev Containers and Docker by scoopertrooper on Thursday January 21, 2021 @10:42PM (#25868055)
Isn't that essentially what mac Docker Desktop does?
Re:VSCode, Dev Containers and Docker by IggleSniggle on Friday January 22, 2021 @10:05AM (#25872207)
Correct.
Re:VSCode, Dev Containers and Docker by ItalyPaleAle on Thursday January 21, 2021 @11:13AM (#25860421)
Speaking for myself, containers are started and destroyed faster. When using VMs, the tendency is to keep updating the software within the VM, making changes to their state, etc: this eventually leads to drifts. When using containers, if you need to make a change, you destroy the container and re-build it, and the state is always consistent with what you (and possibly your teammates) use
Re:VSCode, Dev Containers and Docker by Shicholas on Thursday January 21, 2021 @08:43PM (#25867183)
as an addition to do this, we've found it easier to spin up the same exact environment for CI/CD.
Re:VSCode, Dev Containers and Docker by adamkl on Thursday January 21, 2021 @11:31AM (#25860682)
To be perfectly honest, in this scenario, there isn't much of an advantage.

The container approach is lighter weight, and I found it easier to manage the configuration via Dockerfiles. Managing a full VM with the OS install is a bit of a pain.

That being said, I worked at an organization that did the VM approach using Vagrant. It wasn't as nice as the VS Code/Docker approach, but the results were similar.

Re:VSCode, Dev Containers and Docker by lpasselin on Thursday January 21, 2021 @10:51AM (#25860133)
Have you tried docker on Windows? It's even worse.

On OSX I only had problems with GUI running in docker. I was used to sharing X between linux host and docker container also running linux.

For some projects, the only working solution I found was to run a VNC server in docker. Specific example: in a docker container, run a GUI built with Kivy and view the window on the OSX host. If anyone manages to do this without VNC, I'd like to know how!

Re:VSCode, Dev Containers and Docker by nickjj on Thursday January 21, 2021 @11:02AM (#25860264)
> Have you tried docker on Windows? It's even worse.

I've been running Docker on Windows since Windows 10 17.09 or roughly the time WSL 1 came around. That's since October 2017.

It's been really fast and stable here and now with WSL 2 it's even better.

There hasn't been a single Flask, Rails, Phoenix or Webpack related project I've developed in the last 3+ years where I felt like Docker was slowing me down[0]. I'm using a desktop workstation with parts from 2014 too (i5 3.2ghz, 16gb of memory and a 1st gen SSD). About a month ago I made a video showing what the dev experience is like with this hardware while using Docker[1].

Code changes happen nearly instantly, live reloading works and even Webpack happily compiles down 100s of KBs of CSS and JS in ~200ms (which could further be improved by using Webpack cache).

[0]: The only exception to this is invalidating cached Docker layers when you install new dependencies. This experience kind of sucks, but fortunately this doesn't happen often since most changes are related to code changes not dependency changes.

[1]: https://nickjanetakis.com/blog/for-the-time-being-16gb-of-ra...

Re:VSCode, Dev Containers and Docker by GordonS on Thursday January 21, 2021 @11:10AM (#25860381)
Also been using Docker on Windows 10 since around the 2016/2017, and also had no issues with speed - it works marvellously!
Re:VSCode, Dev Containers and Docker by tmpxgdqrcKFuG on Thursday January 21, 2021 @11:27AM (#25860632)
The problem is "technically" still there in Windows it's just that Microsoft decided to push things along by creating WSL which essentially puts Linux (with Linux Containers) on Windows.

The Windows solution is the equivalent of Smart Hulk figuring out time travel.

I'm not saying it's not good, because it is.

Re:VSCode, Dev Containers and Docker by RyEgswuCsn on Thursday January 21, 2021 @11:07PM (#25868203)
I have been using Docker powered desktop environment for development on WSL2. Didn't have any issue except that I couldn't access the containers via their internal IPs inside WSL2.
Re:VSCode, Dev Containers and Docker by mgomez on Thursday January 21, 2021 @11:08AM (#25860348)
> Have you tried docker on Windows? It's even worse.

In my experience, Docker on Windows with WSL 2[1] has been pretty snappy.

[1] https://docs.docker.com/docker-for-windows/wsl/

Re:VSCode, Dev Containers and Docker by alanwreath on Thursday January 21, 2021 @05:09PM (#25865117)
I wonder what the stats are of the VSCode remote plugin users but I would wager a cup of water that the majority of users who go this route are dealing with Windows in some fashion. I’d never heard of such witchcraft until I moved to an organization that, for whatever reason, has deemed that Windows laptops are the mandatory choice for web development. WSL does have significant problems (and even when it works you deal with the idiosyncrasy of the magic it does to interact with the Windows environment : try installing docker solely in your wsl2 environment and you’ll find it still looks for an .exe executable or have fun figuring out why some so trivial doesn’t work like it used to because it depended on systemd which is purposely absent from operating systems you might install on WSL2). In truth using WSL2 is a trick, and can add headaches to anyone who doesn’t want to deal with the added abstraction of running another operating system that interacts with your native operating system in ways neither were originally built for. That’s not to say that WSL2 isn’t impressive. It has the ahah that parallels, codeweavers, or wine (to name a few) kind of all bring when they work. And when they don’t it’s also time to get lost in the weeds. But now, especially in its infancy, WSL2 has problems. Why wouldn’t it? It’s new to Windows offerings and relatively obscurely tested given the audience is a small fraction of what they’re up to.

This solution of VSCode + Docker containers seems to sidestep the whole WSL issue as WSL is no longer necessary for development if you’re containerizing everything anyway. While, I must admit, I like the idea of a project having the same steps for all users regardless of platform (to each his own), I don’t believe the majority of people would like to ditch their IDE of choice for the one tool that does this somewhat seamlessly. I’m probably not characterizing this well as I’m new to the workflow and I like to customize my own terminal workflow - which from what I’ve seen this doesn’t lend well to. Lemme just say it - I like the Linux cli workflow more than Windows and have since the beginning. But that’s just me. I’m sure their are plenty of peeps who feel the opposite. What I don’t like and I feel I share the same annoyance is now having to know both Windows and Linux command line interfaces.

Yes you’ve stepped into a rant, gotcha!

Here’s to hoping Microsoft goes full retard and strips out Windows and just maybe go the Edge route: shifting to putting a pretty face on Linux. That would be awesome, I’d buy Microsoft’s distro, frickin base it off Debian and let’s get this show going! Apple ain’t really doing anything special at this point - so your move Satya!

Re:VSCode, Dev Containers and Docker by 40four on Thursday January 21, 2021 @10:56PM (#25868132)
“I’d wager a cup of water”

I like this phrase. I would like to borrow it if you don’t mind :)

Re:VSCode, Dev Containers and Docker by alanwreath on Thursday January 21, 2021 @11:04PM (#25868187)
Me recently getting into Dune has altered my perception...
Re:VSCode, Dev Containers and Docker by Iwan-Zotow on Thursday January 21, 2021 @11:12AM (#25860411)
WLS2, docker desktop, running it for couple of years, so far so good
Re:VSCode, Dev Containers and Docker by misiti3780 on Thursday January 21, 2021 @10:46AM (#25860068)
Agreed, try running webpack in debug mode with watch it's basically not-usable, as is git and install npm packages.
Re:VSCode, Dev Containers and Docker by GiorgioG on Thursday January 21, 2021 @10:59AM (#25860225)
npm / webpack: That's not Docker's fault - that's node/JS's fault. Having to touch thousands and thousands of files is expensive. This is why I've come to loath web frontend development.
Re:VSCode, Dev Containers and Docker by onion2k on Thursday January 21, 2021 @11:14AM (#25860427)
It's definitely Docker that's the problem. It's a well known problem, and people are working on solutions. It affects far more than NPM and Webpack.
Re:VSCode, Dev Containers and Docker by commandlinefan on Thursday January 21, 2021 @11:11AM (#25860393)
> I've come to loath web frontend development.

Well, we don't have to do things this way just because everybody else does... developing "vanilla" Javascript is actually a pleasure especially with tools like Chrome's debugger. In my experience, front-end "frameworks" like Angular and React provide very little value and tons of unnecessary overhead.

Re:VSCode, Dev Containers and Docker by potta_coffee on Thursday January 21, 2021 @11:36AM (#25860737)
Show me the team that's using vanilla JS, I'd like to sign up.
Re:VSCode, Dev Containers and Docker by Maer4life on Thursday January 21, 2021 @11:15AM (#25860458)
Same problem with PHP development, anyone trying to develop on windows for any real world framework will have epic IO lags, sometimes crashes with composer (equivalent to npm) and ALSO during execution time. Is this composer/PHP/Symfony-Laravel-whatever's fault ? Is it the caching lib fault ?

I work on linux, but try to onboard windows dev frequently ("windows dev", ikr ;) . The experience is always painful, and despite many efforts from the WSL team to move forward, docker for development on Windows is still barely usable right now ...

Re:VSCode, Dev Containers and Docker by cpuguy83 on Thursday January 21, 2021 @11:02AM (#25860270)
I use vscode to connect to a a cloud vm. VSCode is surprisingly good at this. Client is local and connects to an vscode server over ssh.

Granted I work on Azure and the cost of the vm is not something I have to worry about.

Re:VSCode, Dev Containers and Docker by gingerlime on Thursday January 21, 2021 @11:48AM (#25860929)
We also use remote dev boxes, but can VSCode connect to a remote server and connect to remote docker containers?

For example, I don't have ruby installed on the remote dev box, but it is installed inside docker on the remote host. I also don't have ruby or docker running locally.

I think all the linting plugins either expect ruby to be available on the remote host, or inside docker, but not this combo... Is there something I'm missing? (disclaimer: only played a bit with VScode, I use vim on the remote box usually).

Re:VSCode, Dev Containers and Docker by brianm on Thursday January 21, 2021 @12:17PM (#25861326)
> can VSCode connect to a remote server and connect to remote docker containers?

Yes, it can. https://code.visualstudio.com/docs/remote/containers-advance... talks about setting it up.

Re:VSCode, Dev Containers and Docker by gingerlime on Thursday January 21, 2021 @01:34PM (#25862249)
Thank you! looks cool. Hope I’ll figure it out, considering I’m pretty clueless about VSCode
Re:VSCode, Dev Containers and Docker by cpuguy83 on Thursday January 21, 2021 @03:29PM (#25863800)
Yes. Vscode (server) is running on the remote machine. Extensions run on the remote as well.

A new terminal in vscode is a terminal on the remote.

Only the client GUI is local.

Re:VSCode, Dev Containers and Docker by gingerlime on Friday January 22, 2021 @06:17AM (#25870655)
Thank you. I managed to get it working... still I'm not sure about things like ruby-rubocop ... I can install it remotely, but not inside a remote docker container (where my ruby runs)... Any tips?
Re:VSCode, Dev Containers and Docker by pbalau on Thursday January 21, 2021 @09:32PM (#25867577)
Yes, if you can connect the docker cli to the remote host, then vscode can connect too.
Re:VSCode, Dev Containers and Docker by speedgoose on Thursday January 21, 2021 @11:08AM (#25860355)
The Azure Codespaces VMs were awfully slow on IOs. It was not a great experience at all.

If you want decent IOs, better than an old notebook, Azure is extremely expensive.

Re:VSCode, Dev Containers and Docker by TimTheTinker on Thursday January 21, 2021 @11:10AM (#25860391)
I do this, but with a Linux VM running in Parallels on my Mac. Uses about 1/10 the CPU that Docker on Mac uses for the containers I run.
Re:VSCode, Dev Containers and Docker by seabrookmx on Thursday January 21, 2021 @11:32AM (#25860697)
Same here, but with Hyper-V on Windows.

Originally I did this because of bad performance and bugs in WSL 1. I hear WSL 2 is better but I already have it all set up and it works great for me so I've just kept it.

Re:VSCode, Dev Containers and Docker by blopker on Thursday January 21, 2021 @11:15AM (#25860446)
There's a volume feature that sped up disk access to mounted volumes quite a bit. You add ":cached" to any volume. This changes some of the guarantees around consistency, but I haven't had any issues. See https://www.docker.com/blog/user-guided-caching-in-docker-fo...
Re:VSCode, Dev Containers and Docker by carlosf on Thursday January 21, 2021 @12:29PM (#25861463)
Not sure about OSX, but in Windows 10 + WSL 2 Docker development can be made faster by cloning code directly to a volume.
Re:VSCode, Dev Containers and Docker by ihuman on Thursday January 21, 2021 @11:38AM (#25860765)
Isn't Docker using virtual machines on macos?
Re:VSCode, Dev Containers and Docker by efficax on Thursday January 21, 2021 @11:04AM (#25860292)
the solution to this is to enable NFS for your volumes. The default volume configuration is a huge bottleneck for docker on macos
Re:VSCode, Dev Containers and Docker by deergomoo on Friday January 22, 2021 @03:47AM (#25869705)
Although be aware, if you add shares to nfs.conf, your Mac will no longer sleep while connected to power, even if you close the lid.

Not sure if there's a way around it, but I was sitting down at my desk every morning to find a toasty laptop, lid closed and fans blaring.