How does a DOCKER communicate with a Windows client - linux

I understand that Docker runs on Linux kernel
Lets say, I deploy an application (SORRY!! I can't disclose the application due to confidentiality reasons) on a CentOS Docker image. The application is known to be compatible with both Windows and Linux.
So now, if I want to run some some program/script on that deployed image but the client that I am using is Windows. Here are two questions that I have,
Is it even possible to use Windows machine to execute the programs/scripts in the remote Docker image?
If answer to question 1 is yes, then how are the system calls in Windows mapped to the equivalent system calls in the Linux environment of Docker.

Is it even possible to use Windows machine to execute the programs/scripts in the remote Docker image?
No: you would need to run the docker image in a Linux VM running on your Windows.
The system calls would be to the VM Linux kernel.
A docker image for Windows (server 2016) would be built specifically for Windows.

Related

In Docker Desktop for windows 10 with WSL2, where does docker containers live & how Linux containers can run a java app, but not windows nanoserver?

I have Windows 10 Enterprise Version and I have installed Docker Desktop, enabled WSL2 backend, and downloaded and installed the Linux kernel update package.
I am learning Docker and I have some doubts about how Docker works behind the scenes.
I have drawn a basic architecture diagram of Docker on windows with
WSL2, is this correct?
Whenever we create a new Linux container it gets created in the same lightweight utility VM provided
by WSL2?
And if we create a windows container it gets created on windows os?
Can these containers access windows and Linux kernels both when
required? Like when running a java app in a Linux container it requires windows kernel, right?
So, by default docker runs Linux containers, when do we need windows containers? I can containerize a java application by using
openjdk:8, but I am not able to pull windows nanoserver image when I
run Linux containers, it works only when I switch to Windows
Containers. What is going on here? Does this mean the openjdk:8 image is a Linux image(i do not know how to say it), and windows nanoserver a windows image?
How Linux Containers can run my java application? It must need the
windows kernel, right?
If the docker containers reside within the lightweight utility VM
created by WSL2, can it access both the Linux kernel that it ships
with and the Windows Kernel?
I have the default Linux container mode and I tried these two
commands.
docker run --platform=linux -d ubuntu /bin/sh -c "while true; do echo
hello world; sleep 1; done"
docker pull mcr.microsoft.com/windows/nanoserver:1903
The first one worked for the second one I got the following error.
1903: Pulling from windows/nanoserver no matching manifest for Linux/amd64 in the manifest list entries
But when I switch to windows containers it works.
So what is the difference between my java app on openjdk:8 image and windows nanoserver?
Do these not require windows kernel to run?
How is the java thing running on Linux containers then?
Edits :- Need more clarification on this-
Copying the question from comment section.
And one more thing, the containers do not access windows and Linux kernels simultaneously in WSL2 right? After all they are just isolated spaces in an OS, so either they can be in windows or Linux? Please correct me if I am wrong. The Linux images are built in such a way that it has everything to run my java and as java is a cross platform language so it can run on Linux kernel, is this the concept?
About the architecture diagram that I have made here- the containers(isolated processes in an operating system with app files) , in case of Linux containers all of them(multiple containers) runs on the same WSL2 VM, right?
Firstly, good question.
I hope I can answer it as best as possible.
So, by default docker runs Linux containers, when do we need windows containers?
you don't need windows containers. You should always consider what your application needs. For instance, if you are working on a java app, you would pull a java image and not an entire host OS. The only time I ever pulled a windows image was when I dockerized an ASP.NET application that can only be run on windows.
How Linux Containers can run my java application? It must need the windows kernel, right?
In the context of docker:
Docker for Windows allows you to simulate running Linux containers on Windows, but under the hood a Linux VM is created, so still Linux containers are running on Linux, and Windows containers are running on Windows.
if the docker containers reside within the lightweight utility VM created by WSL2, can it access both the Linux kernel that it ships with and the Windows Kernel?
Containers are using the underlying Operating System resources and drivers, so Windows containers can run on Windows only, and Linux containers can run on Linux only. Docker for Windows allows you to simulate running Linux containers on Windows, but under the hood a Linux VM is created, so still Linux containers are running on Linux, and Windows containers are running on Windows.
So what is the difference between my java app on openjdk:8 image and windows nanoserver?
The openJdk image and windows nano server core difference is the very base image that they use. openJdk is probably using some very bare unix os as the base where as the nanoserver is an entire os which is windows.
Do these not require windows kernel to run?
The openjdk image does not require windows to run as it is built from linux. Docker for windows will use the WsL to run. The nanoserver will only run on windows (as windows images can only run on windows).
How is the java thing running on Linux containers then?
I understand this question to be "How does the openjdk image run on linux and windows?"
if so, because it uses a linux os as its base image, it can run by default on linux. But because the WsL2 exists, a VM is created and simulates a linux OS in windows. That is why we can run windows images and linux images on Docker for windows.
I hope this helped, here are some extra tips from the questions for you to consider.
The images will always perform best when the image is the same type as the OS. This is because docker will utilise resources of the host and performance is better when the host and container are of the same os.
Use images that are best fit for purpose. Don't use an entire os image just to run a java app. Rather use the java image. This applies to a wide range of frameworks and languages.
Read this This is the crediting article if you want to read more.
The diagram is not quite correct. Both the Windows Kernel and a lightweight VM that hosts WSL2 KVM sit on top of the Hyper-V hypervisor. In other words, WSL2 leverages Hyper-V. (An alternative would be to use only Hyper-V, but with WSL2 it is more seamless.) WSL2 uses docker-desktop as the main bootstrap VM and docker-desktop-data for storing images and containers data. 9p network protocol is used for seamless host-to-guest and guest-to-host file access:
https://wiki.qemu.org/File:9pfs_topology.png
This way, docker commands can be run from both Windows and from within a distro installed under WSL2 such as Ubuntu etc. In both cases, containers run under Linux. A rationale for this architecture is that Linux Docker cannot be installed on Hyper-V VM nor inside a WSL2 Linux.
Hi,
In practice exist two great use-cases/types of hypervisors:
a)Hyper-V is hypervisor(software which controls the containers=VMs) which is type-1 so it worked directly(bare-metal) on machine=PC=hardware:
Hyper-V(hypervisor type-1) <---->PC-machine
In this first type The Hypervisor take control over hardware directly(it avoid using of the Host-OS because the control taken from machine's BIOS)
That means that not use Host-OS but not means that Host-OS not exist!!!!
b)Virtual Box(VB) is hypervisor type 2(heavy software). So VB worked with machine via Host-OperationSystem(Host-OS):
VB(hypervisor type2) <---> Host-OS <----> PC-machine
So in this last case the control of hardware(PC-machine) is heavy because the control over machine=PC=hardware is exercised via supplemental or tertial-part=component which is Host-OS
Also need to know that the containers=VMs(regardless of type 1 or 2) have each the OS one but it is named OS-guest(fr. invite).
So in both case(type 1 and type 2) the Hypervisor work as backend for containers/VMs(which are frontends).
For more details read about in this tutorial/article:
https://www.nakivo.com/blog/hyper-v-virtualbox-one-choose-infrastructure/
PS: One Virtual-Machine (VM) can controls many Containers like in the image
Thanks
or use this google images search(firstly 3 images)
Another explanation about communication from VM and its isolated-Containers can be fount in this article.

Is running a Linux container on windows AWS instance possible?

I'm trying to run a Linux (ubuntu LTS) container inside a windows server 2019 OS. The problem is that the windows OS runs as an AWS instance.
There have been problem for me trying to achieve this and I've been reading somewhat different opinions on the internet regarding whether or not it is possible. Some say it will be possible on a .metal instance which is bare metal. Currently I've been trying running it on a regular t3 instance with has virtualization type HVM.
To sum up my questions are:
Is running a linux container on windows aws instance possible?
If yes, how?
If not, will it be possible on a bare metal instance?
Please keep in mind that I need the container to run in a Windows environment due to multiple tasks the the OS needs to achieve (and I don't want multiple instances)
In order to use Docker Desktop on Windows, you need either Hyper-V or Windows Susbsystem for Linux enabled (which at its turn requires Hyper-V). Both solutions demand of VT-x capabilities, but you're running inside a VM, which means that is not so easy to achieve.
It is called "nested virtualization", and it is not supported in common EC2 virtual machines. (source)
You can certainly run Linux containers on a bare metal Windows instance (but why you should? it is way cheaper and simpler to create a Linux virtual machine on EC2 and communicate it with your Windows host). Should still that be your purpose, you can install Windows Server 2019 with Hyper-V. (tutorial)
Another alternative for SMALL, SMALL things, that could work without nested virtualization (I haven't tried), would be using WSL1. (more info)
WSL1 uses a compatibility layer between Windows and Linux system calls, without actually virtualizing the operating system. Some folks have been able to install Docker 17.09 on WSL1, but this is a very adventurous path I would not recommend taking.

How to create Docker container in windows to run in ubuntu vm

I have three small Springboot Microservices and a plan. I have to say that I develop in Eclipse under Windows10 Home.
My plan is to build a Docker container of each one and run it in a ubuntu VM on my Windows pc, so that I can use the containers in a real linux server in the future.
Does this work? What do I need? Is there a Docker for Windows that builds container for linux? How do I deploy the container to the vm? Do I have to push it to dockerhub first? Can I access the container from a Windows Browser by some kind of port forwarding?
Thank you for your help....every hint is welcome.
You can use Docker for Desktop Windows with WSL 2 running a Ubuntu distro. It's the best setup to develop Docker for Linux, because of the incredible interoperability:
Both OS run side by side, sharing the same Docker environment (images, containers, compose sets, etc). You can manage, configure using Docker tools on either OS, switching back and forth easily
Both OS share the same file system, so you can develop config files with your favorite Windows editor which are equally accessible from Linux
Both OS share the same network, so you can access services, API from one to another via port forwarding (using browser in Windows and Curl in Linux to access same resources)
The close interoperability means no need to deploy across systems, since you have only one shared environment.
Since you develop in one place locally, no need to distribute images to remote repositories
As a bonus, Docker for Desktop ships with a fully working single cluster version of Kubernetes providing the same shared environment
Go for it then, unless your machine has limitations against WSL.

Is there any os virtualization without having to install a full OS (needed multiple similar vms)?

I wanted to have a separate virtualized OS environment (preferably Windows but Linux is also welcome) but running on a very small RAM to run a bot application.
I have tried Hyper-V (with disk differencing) and VMware (with linked/instant clones) and Virtualbox and qemu but so far they need full OS installation and it can take up so much space.
Basically I just needed multiple similar environment (close to 100) without having a big HDD space and I run all the apps from a local network folder.
(Similar to multiple vms running under one vhd but I dont want to take up so many HDD spaces)
I have tried using one customised Lubuntu livecd and WINPE live cd (Gandalf's WINPE 7) booting on multiple Hyper-V vms. They boot just fine but Gandalf's WINPE is not a full windows and require a high RAM usage while on Linux side I cant run my windows script + app well under WINE though Linux memory management is much better and I still can use a much smaller distro like Damn Small Linux if need be.
I checked Microsoft's App-V but it just virtualised the app not setting up a new standalone environment. I need a new environment with their own mouse pointer but needing very small RAM preferably just for running the bot and the app.
Thank you.
I have tried FreeBSD Jail, LXC, LXD, but unable to make it the way I want it to be (having one PC with multiple users but on a minimal footprint).
However, I am excited that I kind of find the solution and would like to share it.
For Windows host machine + Linux guest
Enable Hyper-V in Windows (if supported) or download VirtualBox
Install Docker for Windows
Install RealVNC (or any other VNC client)
Download (pull) or create any linux docker image with desktop
environment + VNC (optional: wine, winetricks, playonlinux for running windows apps + cimb-utils [it is for smb sharing network folder])
In powershell deploy multiple container using same image + assign each
different vnc port, for example :
For VNC + Samba network sharing + vncpassword
docker run -it --user 0 -d -p 5900:5900 -e VNC_PW=passwd --privileged --cap-add SYS_ADMIN --cap-add DAC_READ_SEARCH --security-opt seccomp=unconfined ubuntu
For only VNC without vncpassword (depends on container)
docker run -d -p 5900:5900 abrahamb/lubuntu-vnc
docker run -d -p 5901:5900 abrahamb/lubuntu-vnc
docker run -d -p 5902:5900 abrahamb/lubuntu-vnc
etc
Open RealVNC and setup a connection to these addresses; for example :
localhost:5900
localhost:5901
localhost:5902
etc
Each ports will lead to separate containerised desktops
That way, you will have one base image for deploying multiple containers (like having one computer multiple users running at the same time) only requiring minimal RAM usage and Disk Size.
Another way is to boot a base live iso in multiple Hyper-V VMs. However, they are RAM intensive and can only deploy several separate environment.
Further info+findings:
Docker is actually kinda similar to LXC, LXD, and FreeBSD Jails since they are all containerised image. I believe if I try hard enough I can make similar setup in LXD. FreeBSD Jails might be a good alternative too.
However, I didnt try further since I couldnt find enough information regarding jails setup. I couldnt find any Youtube video that explains how to setup, only some articles/blog but still too frustrating since I dont have enough time to research further.
LXD/LXC can be configured to virtualize a desktop but not quite what I am looking for since that would mean I have to dual-boot/have Ubuntu vm.
Docker just recently implement Windows container but the base image is GUI-less. In the Linux side however, there are quite a few available images that have been configured with bare minimal desktop environment.
Also, using Docker, I dont need to have VM that is running Ubuntu/FreeBSD to setup lxd/lxc/jails or dual-booting Linux/FreeBSD. Another plus, Docker is cross-platform (can be used in Windows/Linux/MacOs).
tldr; Docker is awesome.

How to create LPAR/WPAR in linux?

I am aware of creating LPARs via HMC and WPARs from LPAR on AIX
But, on my laptop (company owned), how can I create a WPAR (or) WPAR equivalent on RHEL 6
You can't create true Linux based WPARs, as this is something that is done within the AIX Virtual Machine (LPAR). Probably something that is like it in a way, is a Linux Docker host and containers (clients), in the same way WPAR uses related libraries for the versions of AIX in the WPAR host. Docker does this too, but in a more feature rich environment.
I recommend that you take a look at the 'Getting Started With Containers' page on the Docker website.
I myself run a VirtualBox VM inside my laptop as a Docker host enabling me to create many if not hundreds of docker containers.

Resources