How to have a source code and IDE on local laptop and run it on another machine inside the docker container? - macos

I'm using an "old" MacBook Pro 2015 with "just" 16GB of RAM for developing some complex websites based on Drupal. As a tool stack, I'm using Docksal (a Docker-based env) and PHPStorm as an IDE.
Because the Drupal site is complex it eats up almost all my memory and the NFS sharing is also very slow. I have another machine (an old Mac Mini) with 16GB of RAM. My idea is to have the code and IDE on my laptop and run the heavy Docker on a second machine.
I found the Docker Context tool and I've configured it to connect to the Docker host on the second machine, so now I can run docker commands on my laptop and they will be executed on the second machine.
But I'm still missing the last part of the puzzle - how can I configure Docker and Docksal to sync my code from the laptop to the Docker image on another machine? Is it possible at all?
Also, I found a Mutagen.io but it is not supported in Docksal and it's not clear how to combine everything together.

Related

Performance issues on WSL 2

For the last two months I've (tried to) embraced WSL2 as my main development environment. It works fine with most small projects, but when it comes to complex ones, things start to slow down, making working on WSL2 impossible. With complex one I mean a monorepo with React, node, different libraries, etc. This same monorepo, on the same machine, works just fine when running it from Windows itself.
Please note that, when working on WSL2, all my files are in the linux environment; I'm not trying to access Windows files from WSL2.
I've the latest Docker Desktop installed, with WSL2 integration and kubernetes enabled. But the issue persists even with Docker completely stopped.
I've also tried to limit the memory consumption for WSL2, but that doesn't seems to fix the problem.
My machine is an Aero 15X with 16GB of ram. A colleague suggested upgrading to 32GB of ram. But before trying this, or "switching back" to Windows for now, I'd like to see if someone has any suggestions I could test out.
Thanks.
The recent Kernel version Linux MSI-wsl 5.10.16.3 starts slower than previous overall.But the root cause can be outside WSL: if you have a new NVIDIA GeForce card installed Windows gives it to eat as much memory as it can, i.e 6-16 Gb without using it. I had to limit WSL memory to 8Gb to start WSL service without OoM. Try to play with this parameter in .wslconfig in your home directory and look at the WSL_Console_Log in the same place. If the timestamps in this file are in ms my Kernel starts in 55 ms and then hangs on Networking(!!!).
I'm afraid that WSL Kernel network driver
lshw -c network
*-network
description: Ethernet interface
physical id: 1
logical name: eth0
serial: 00:15:5d:52:c5:c0
size: 10Gbit/s
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=hv_netvsc driverversion=5.10.16.3-microsoft-standard-WS duplex=full firmware=N/A ip=172.20.186.108 link=yes multicast=yes speed=10Gbit/s
is not so fast how it is expected to be

Docker for windows 10 home edition

For installing docker on windows home edition , there are two options if I don't want to run virtual machine.
Which is better :
installing docker desktop ?
installing using wsl2 ?
I'm not going to answer which one is better but instead present some points you should consider before choosing one. However, if you're using Windows Home Edition, I'm afraid your choice is to either:
upgrade to Windows Pro and install Docker with the original Windows backend
install WSL2, then install Docker with the WSL2 backend
This is mentioned on the Docker website. Instructions for Windows Home/WSL2 here and for Windows Pro/Non-WSL2 here.
Bind mount performance
If you care about bind-mounts, where you share a directory between the host OS filesystem (Windows) and the container filesystem (usually Linux), you'll want to compare performance between these two options.
If you want faster bind-mount performance on WSL2, you should mount shared files in the Linux filesystem (the part of your system dedicated to WSL2) for mounting. So you'd want to use \\wsl$\Ubuntu-18.04\home\<user name>\Project instead of C:\Users\<user name>\Project. Docker has more info about this here and Microsoft has more info here.
Start time
Other points mentioned on the Docker website include that Docker has a faster cold-start time with the WSL2 backend compared to the previous version.
Changing Docker system settings
Using WSL2, you'll also have to modify the WSL2 configuration if you want to reduce the amount of memory Docker can use for example. See details here as referenced from the Docker on WSL2 best practices.
I see no two options, at least in the terms you used stating the questions.
On Windows 10 you install Docker Desktop and this can have WSL2 as backend.
On Windows 10 Home, specifically, you can install Docker Desktop with WSL2 backend.
For reference see "Install Docker Desktop on Windows Home" documentation page where only one option is described, and not two.

Docker Container vs Virtual Machine

I am using docker desktop on windows 10. I downloaded an image for windows server core 1909.
then created two containers from the same image.
Docker run -it mcr.microsoft.com/windows/servercore:1909 powershell.exe
when I ran sysinfo on both, it gave me different hostname for both OS.
how do I see that kernel is shared? because I see these are two different VMs which is no different than hyper-v VM of the core OS.
I though docker container is sharing a kernel but I don't see the same OS underneath?
any idea?
Ok i got the answer also. There is concept of hyper-v isolation level for containers in windows. so if the host is not same version as of the container, you will get what you call hyper-v isolation which is essentially not a process isolation, its rather a virtual machine like traditional thing. no shared kernel.
True container concept which is actually shared kernel is only possible on windows server host and when used container version which is also same.
https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility?tabs=windows-server-1909%2Cwindows-10-1809

Docker on Windows 10 Home

My question is: If you use Docker tool box (that is required for windows 10 home to run Docker) you are essentially using a virtual machine (vm)?
If you are using a vm already the only reason to use docker from that point is to save on many more multiple instances?
Meaning if you only want 1 extra (guest instance): you can have a vm. Though, with docker (toolbox on windows 10 home) you would have 1 vm and it runs docker?
The only way that is useful is if you want many more instances as in: 1 vm + 1 docker or + 1000 more dockers?
Or am I missing something?
Yes, docker toolbox uses Oracle VirtualBox cause Windows 7, 8, and Windows 10 home cannot use Hyper V. And yes, If you are using a VM already the only reason to use docker from that point is to save on many more multiple instances but it also allows easy backup and deployment. But you are losing a decent amount of memory when running a VM and then even more when you are running docker.
So although Docker CE will tell you your Windows doesn't support Hyper-V, this isn't always the case (if you check in System Info you might have Hyper-V enabled, if you're on an Insider build or many builds on GPU computers after Anniversary update then you probably have Hyper-V on Windows 10 Home). There are a few workarounds until the Docker team addresses this issue.
You could use Docker from inside WSL (Windows Subsystem for Linux). Microsoft claims WSL accesses everything directly without Hyper-V so this should be theoretically at the same speed. Of course you can't use your GPU at all because of limitations with GPU passthrough on WSL, which you can ask to be resolved here.
You can also use Docker Toolbox as the other answer stated with Virtualbox, but this will be inherently much slower as you're virtualizing a container inside a virtualized container. You should be able to theoretically get GPU support through this, as well as other features e.g. GUI that you wouldn't be able to with WSL.
To answer the "usefulness" portion of the question:
It's also useful if you run code on a server, but need to develop/debug/update it. You want to test it locally, but to make sure the environment in which it executes is the same (to avoid unexpected, environment specific behavior), you use Docker both locally and on the server. In such a case, even though it's slow, I'll spin up a VM on my W10 Home laptop and run Docker in it.
The greatest feature of the Windows 10 Home May 2020 Update is Windows Subsystem for Linus 2. You can docker in it without the need for a complete virtual machine as in Virtual Box.
Install Docker Desktop that it will automatically indentify WSL2.

Could I use docker or something similar to deploy windows application?

I am running a game on Windows, and it requires every OS can only run one. And If I want to run more, currently I open vmware and run the game inside. But the problem is it takes too much memory and disk to run a whole another virtual OS. I know docker will reduce this, but it doesn't seem to support Windows.
Am I right? If so, any other solutions?
Docker uses LXC (linux containers) so cannot run a Windows operating system.
You can use docker on Windows using a boot2docker VM, but this is not the same as docker running a Windows operating system (your containers will run unix based operating systems inside the boot2docker VM).
To do what you're after, you'll need to use separate VMs.

Resources