this post was submitted on 27 Aug 2023
40 points (91.7% liked)

Selfhosted

40233 readers
750 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

Folks, I have a node.js script running on my Windows machine that uses the dockerode npm package to talk to docker on said box and starts and kills docker containers.

However, after the containers have been killed off, docker still holds on to the memory that it blocked for those containers and this means downstream processes fail due to lack of RAM.

To counter this, I have powershell scripts to start docker desktop and to kill docker desktop.

All of this is a horrid experience.

On my Mac, I just use Colima with Portainer and couldn't be happier.

I've explored some options to replace Docker Desktop and it seems Rancher Desktop is a drop-in replacement for Docker Desktop, including the docker remote API.

  1. Is this true? Is Rancher Desktop that good of a drop-in replacement?
  2. Does Rancher Desktop better manage RAM for containers that have been killed off? Or does it do the same thing as Docker Desktop and hold on to the RAM?

Are there other options which I'm not thinking of which might solve my problems? I've seen a few alternatives but haven't tried them yet - moby,
containerd,
podman

I don't actually need the Docker Desktop interface. So pure CLI docker would also just work. How are you all running pure docker on Windows boxes?

all 37 comments
sorted by: hot top controversial new old
[–] dandroid@dandroid.app 21 points 1 year ago (2 children)

I despise Docker Desktop. Before I knew anything about docker or containers, all I knew was that it was in the required software list for my work for building our software. All I knew was that if it wasn't open, my build would fail and if it was open, my laptop would slow down to a crawl.

Eventually I took classes on Docker for work and learned quite a bit about it. I learned that I could use docker from command line with no UI, and I wouldn't take anywhere near the performance hit. I eventually linked my IDE docker runtime to podman running on WSL2. Now I take pretty much no noticable performance hit.

TL;DR: you can replace Docker Desktop with WSL2 command line commands and have no UI.

[–] damnthefilibuster@lemmy.world 2 points 1 year ago (2 children)

thanks for that :)

BTW, if I fire up a bunch of docker containers in WSL2 using podman or native docker, and then kill them, does WSL2 release the RAM it acquired to run those containers?

[–] boo@lemmy.one 1 points 1 year ago (4 children)

At this point i would just install a linux distro like ubuntu/debian/arch as a VM on virtualbox/vmware/hyperv and do it from there, WSL2 is supposed to be custom ubuntu minus gui running on hypervany way.

[–] FooBarrington@lemmy.world 3 points 1 year ago (1 children)

And as such it's perfectly suited for what OP is trying to achieve. A custom VM will be a lot more work than using WSL2.

[–] boo@lemmy.one 1 points 1 year ago (1 children)

I wouldnt say a lot, maybe its more, but i would estimate 15min for wsl2 vs 45min for virtual box. Plus you get lot more featues than plain wsl2 and its quirks.

[–] FooBarrington@lemmy.world 3 points 1 year ago (1 children)

WSL2 is already installed and running without any extra setup required, so all the setup time for the VM is additional time you have to spend. You'll have to fiddle a lot longer than 45min the first time you set it up if you want parity with the WSL2 installation (bidirectional mounts, bidirectional network access, GUI applications as normal windows, integration into Terminal etc). Until everything is running you'll probably spend half a day, since you'll have to first look up how to best do these things for your VM environment. Even more so if you want to use Windows tools with WSL2 integration, like the whole IntelliJ suite.

What features and quirks are you referring to?

[–] boo@lemmy.one 0 points 1 year ago (1 children)

Is it pre installed nowadays? I rember having to go to some store and doing stuff to get it...

Mounts and networks should be just checkboxes, dropdowns iirc.

Terminals are probably better on linux anyway, if we really want the stone age windows tools we can always ssh into it from windows.

I didnt really get the gui part, linux vm can have, and run GUIs, all the intellij stuff are available for linux natively. Even then iirc they can run with any linux remotely as well, just needs ssh. If you need it to run on windows like native apps, maybe use Xserver via ssh.

As far as quirks I read some comments in this thread about filesystem being too slow, maybe there are more.

And now that i have typed all these, if you want it to look and feel exactly as windows withput any compromise, idk...

[–] dan@upvote.au 2 points 1 year ago* (last edited 1 year ago) (1 children)

Terminals are probably better on linux anyway, if we really want the stone age windows tools

Wut? The Windows tools are a lot newer than the Linux ones. Windows Terminal is better than anything preinstalled on a Linux desktop IMO

[–] elbarto777@lemmy.world 1 points 1 year ago (1 children)

What are some features that the new windows terminals have that linux terminals don't?

[–] dan@upvote.au 3 points 1 year ago* (last edited 1 year ago) (1 children)

It supports tabs out-of-the-box (not all the Linux ones do).
It supports profiles so you can have easy access to different commands/shells along with keyboard shortcuts to create a new tab using a specified profile:

Profiles aren't just for the entire window - You can use a different profile per-tab (I think GNOME Terminal forces you to use the same profile for the entire window).
You can customize colours and fonts per profile. Has a nice font by default (Cascadia Mono).
It's hardware-accelerated, so fast-scrolling text doesn't lag.
Full UTF-8 and UTF-16 support.
Full accessibility (screen readers, etc) support.
Search.

Linux terminals may support all these features now... Which one do you use?

[–] elbarto777@lemmy.world 1 points 1 year ago

Thank you! I use whatever default terminal comes with Ubuntu, and it sucks.

[–] eek2121@lemmy.world 3 points 1 year ago (1 children)

WSL2 runs ubuntu on Hyper-V. It isn’t really as custom as you’d think. You can install other distros besides ubuntu. Or you can install regular ubuntu instead of LTS.

Take a look at this for running other distros: https://learn.microsoft.com/en-us/windows/wsl/use-custom-distro

[–] dan@upvote.au 1 points 1 year ago

It's using Hyper-V technology, but it's not just a VM, and can run on OSes that don't run Hyper-V, like home editions. https://learn.microsoft.com/en-us/windows/wsl/faq

[–] Zeth0s@lemmy.world 1 points 1 year ago* (last edited 1 year ago)

Time to share this wisdom with IT security departments of the companies I worked for. Wsl2 is in the zero trust white papers of MS (or whatever IT security uses to take decisions). Real distros are not. Result, no trust...

Enterprise IT... Non sense since the 70s

[–] dan@upvote.au 1 points 1 year ago (1 children)

minus gui

WSL2 supports GUI apps.

[–] boo@lemmy.one 0 points 1 year ago (1 children)

Meant to say a guo DE, not sure you can run plasma/jde on that, maybe with vnc/rdp? But still its with x11 server iirc.

[–] dan@upvote.au 1 points 1 year ago

Why would you need a desktop environment though? You're already running Windows. You can run individual Linux GUI apps, which is enough for pretty much all use cases.

[–] markr@lemmy.world 2 points 1 year ago

The integration of Docker for windows with wsl2 is an abomination that breaks just about every time I update either ddw or windows. Also the fact that it is tied to my user account ( both ddw and wsl2) means that it is not a great choice for persistent services. I still use it to provide monitoring agents for Prometheus and portainer, but otherwise everything runs on Linux vms on my homelab xenserver cluster.

It is possible to install docker without ddw. It’s documented for server versions of windows, but is basically only for running windows containers. The only use case for that is windows build agents as far as I can tell.

Docker can be installed standalone on wsl2 and would be more reliable.

[–] nickwitha_k@lemmy.sdf.org 8 points 1 year ago (3 children)

If you don't need UI, I prefer Podman. Rancher Desktop is good though.

[–] damnthefilibuster@lemmy.world 3 points 1 year ago (2 children)

thanks! So podman supports the docker API completely?

[–] eight_byte@feddit.de 1 points 1 year ago

When I had a look on it a while ago they didn’t support Docker Compose. But except this it’s a drop in replacement.

[–] loren@programming.dev 3 points 1 year ago

Podman Desktop is also a thing

[–] marty@discuss.tchncs.de 1 points 1 year ago

Yes, rancher desktop works perfectly 👍🏻

[–] Zeth0s@lemmy.world 7 points 1 year ago

Wsl2 and podman.

Far from a nice overall experience compared to using docker on a real OS, but the best I could get on windows

First, it's not possible to use "pure docker" on Windows. Docker is for running additional user mode environments under the same kernel. You can't run Linux applications under the Windows kernel without WSL1, and WSL1's Linux implementation does not support the features required for Docker. This is also possible in limited cases with Windows Server, but because of differences in the way Windows works you almost always end up running a second kernel.

WSL2 can be used to run Docker, and in fact that's how Docker Desktop works since years ago. When you start Docker Desktop it starts a WSL2 distribution under which the containers run. Running Docker from the command line only will not positively change the performance of your containers.

Running other virtualization software, especially VirtualBox, to start a separate Linux VM and running your containers in there is going to be more complicated and give worse performance unless you disable all virtualization-based features of Windows, such as WSL2 and security isolation.

The solution to your memory problem is most likely one of the following:

  1. Don't disable the pagefile. Windows uses a weird memory model where all virtual memory must be backed by physical memory. Certain software will allocate virtual memory without using it, and Windows will require that the sum of the physical memory size and the page file size be adequate to use all of that virtual memory. Disabling the pagefile or limiting it to small sizes because you "have enough RAM" will cause out of memory errors while you still have plenty of RAM available.
  2. Reduce the amount of memory that Docker is allowed to use to a level that your Windows software can tolerate. You may need to switch Docker Desktop to Hyper-V mode for this option to be available, which isn't an option if you're on Windows Home, and this may reduce compatibility.
  3. After stopping your containers, run echo 1 > /proc/sys/vm/compact_memory at a WSL2 prompt or wsl -u root -- bash -c 'echo 1 > /proc/sys/vm/compact_memory' from a Windows prompt. See Memory Reclaim in the Windows Subsystem for Linux 2 for details about what this does.
[–] rikudou@lemmings.world 2 points 1 year ago (2 children)

When I had Windows I ran WSL2 + standard Linux docker, worked flawlessly. If you have all your files in the WSL volume, it's also really fast compared to Docker Desktop on Windows or Mac. I found it almost as fast as a native Linux version.

[–] damnthefilibuster@lemmy.world 1 points 1 year ago (3 children)

I thought WSL2 made things slow because of some stupidity they did with the code? Maybe they fixed it.

Anyways, is it able to take as much resources as it needs from the host? Unrestricted in terms of RAM and CPU?

[–] rikudou@lemmings.world 6 points 1 year ago

It's slow when you go cross-filesystem, meaning accessing WSL2 files from Windows, or accessing Windows files from WSL2. If you keep all related files in WSL2, it's really comparable to native Linux experience (with a small penalty due to being ran in a VM, but it's not noticeable by a human eye).

As far as I know, yes, it can take all the resources it needs.

[–] theterrasque@infosec.pub 2 points 1 year ago* (last edited 1 year ago)

is it able to take as much resources as it needs from the host? Unrestricted in terms of RAM and CPU?

https://learn.microsoft.com/en-us/windows/wsl/wsl-config#configuration-setting-for-wslconfig

[–] breadsmasher@lemmy.world 0 points 1 year ago (1 children)

made things slow

That’s probably referring to how file systems are handled. Going from WSL to windows file system is slower than using the “proper” mount point

Unrestricted

yes

[–] damnthefilibuster@lemmy.world 1 points 1 year ago

nice! Thanks! :)

This is what I do as well. I generally use it for testing then deploy it on my home server in a linux VM.