I want to create a docker container which installs an MSI application. I know i will be using the microsoft\widows\servercore image for this. Which host os i should use for this purpose. Will this image can be created and deployed in a Linux distribution??
If you're running a Windows container, you need to use Docker on Windows.
In general, containers can only run on the OS that they're designed for, but it is possible using Docker for Windows and Docker for Mac to run Linux containers since they provide a miniature Linux VM to run those containers. However, Docker on non-Windows OSes doesn't provide a copy of Windows to run containers with, so you have to use Windows to run Windows containers.
If you want your container to be deployable on a Linux host, it will need to be using a Linux container image.
Related
As i understand, docker use linux VM even i install it on windows OS.
So i agree that windows docker can execute linux container.
But then, how windows docker executes windows container?
Can i make container with other OS?
In other words, can i make container(having windows & windows app) and run it on linux docker?
As i know, docker does not support other OS in image, but it looks like some people is saying it is possible that make windows container and run it on linux.
Docker container shares just one kernel, is it possible?
To answer your questions:
That first statement is incorrect. Docker uses the underlying OS feature (container) to run its stack/daemon. The OS is responsible for instantiating the container itself. That means a Linux OS will instantiate a Linux container and Windows host will instantiate a Windows container. So, if you install Docker on Windows you don't have a Linux VM. Instead, you have the ability to instantiate Windows containers directly without the need to run Linux at all. To answer the question itself: The process is pretty much the same as Linux. You pull images with docker pull and then run them with docker run. You can also build images with docker build and everything else.
Windows containers can only run on Windows hosts (either Windows 10/11 or Windows Server). For Linux containers, that's not so strict. You can run Linux containers on Windows for development purposes, by leveraging the Windows Subsystem for Linux (WSL).
There's much more details on these on the Microsoft documentation page: https://cda.ms/4nN
In the previous threads I asked a question about the way to move the Windows Containers into a Azure Container Services, and I received a great help
Deploying Windows Containers (created with Docker) into Azure Container Service
Pushing Windows Containers (built with Docker) into Azure Container Service (ACS) with Linus OS
I successfully created a Docker container on the Windows Server 2016 and through a Docker hub I moved the Docker container into a Kubernetes cluster with Windows Nodes where I was able to run these containers
However, after I ran a demo for my manager, I now need to conduct an additional research as my manager has some questions.
First of all, he is curious why the docker container cannot run on Windows (I do use Docker command when create the container) After all the Docker container should be platform independent and run in any environment, on both Windows and Linux
Also, I understand that there should be a switch between Windows and Linux when running Docker builds. However, on Windows Server 2016 with Containers there is no docker switch. Only command line is available.
Is that possible to switch between Linux and Windows modes on the command line and also, just in case, I am NOT working with Windows Containers, I am trying to work with Docker Containers.
Is that a true statement that a Docker Container with the .Net Core application (which is also cross platform cannot run on Linux)?
Thank you very much for your answer!
he is curious why the docker container cannot run on Windows (I do use
Docker command when create the container) After all the Docker
container should be platform independent and run in any environment,
on both Windows and Linux
To short, containers are not for virtualization, and they are using the resources of the host machine.
Windows container need .dll files, but Linux does not have those .dll files. And Linux based container need libraries, but windows does not have those.
Is that possible to switch between Linux and Windows modes on the
command line
About containers switch, please refer to this article. we can follow this article to configure docker for windows.
Is that a true statement that a Docker Container with the .Net Core
application?
As far as I know, for now, we can't run windows-based container on Linux.
I installed Docker for windows on a windows 10 box. It required me to enable the HyperV feature on it. Everything installed correctly and is running fine.
Although one thing took me by surprise. I am actually able to run a linux container on docker windows. I thought cross-containerization is not possible conceptually. Can anyone please help me understand how does this work?
HyperV is used to spin up a Linux VM to run containers. Docker is still running Linux containers under the covers, the native Windows containers are still being developed.
Basically, you are running a Linux Container on a Linux Machine rather than Windows. Windows runs a VM in Hyper-V when you download the Docker for Windows. You can open Hyper-V Manager and see a Linux VM will be running. Currently Docker for Windows is in beta which supports the Docker natively which needs Windows 10 build no. greater than 14393.222 or a Windows Server 2016.
I'm able to run the ARM images (eg. hypriot/rpi-node) in Docker on Windows (64bit), but in all linux x86/64 machines I've tried (Debian, CoreOS, Alpine etc) I get the following error - which makes sense to me but I dont get why it'd run in Docker on Windows then, and I wonder whether I'm missing some opportunity to use an x86 machine as a build server for ARM images (ie. the in google/aws cloud/azure). Any ideas how I might be able to?
docker run -ti hypriot/rpi-node ls
standard_init_linux.go:175: exec user process caused "exec format error"
Docker for windows (and docker for mac) both use a linux vm to host containers. However, the difference between the linux vm they use and your linux machines is the fact that their VM has a kernel system called binfmt_misc setup to call qemu whenever it encounters a binary for a foreign architecture (https://github.com/linuxkit/linuxkit/blob/1c552f7a9db7f0660d3c83362d241e54142323ca/pkg/binfmt/etc/binfmt.d/00_linuxkit.conf )
If you were to configure your linux machine appropriately, it could be used as a build server for ARM images. Google qemu-user-static for some ideas of how to set it up.
Note that the linuxkit vm uses the 'F' flag which doesn't seem to be standard when configuring a typical linux environment. Without it, you need to put the qemu binary inside the container. I'm not sure why it isn't standard practice to use 'F' in more places (there does seem to be a debian bug to do so https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=868030 )
On Windows and Mac docker works under Linux VM. So, I think, that for your container under Windows started ARM Linux VM. But under native Linux used native architecture.
The "exec format error" confirms that you are not running your docker image on the correct architecture.
I had this error trying to run a x86 docker image on a Raspberry Pi 2 (Which works with an ARM architecture). I am pretty sure it might be the same error when you do it the other way round.
So, as Kulti said, Windows/MAC must have started an ARM Linux VM.
If you wish to work with ARM docker images on Linux, you may want to try running a linux docker VM manually. I think you can do it using "docker-machine" even on linux : Docker documentation for docker-machine. (Haven't done it myself so I am not sure)
Hope this helps.
Docker on Windows uses a Linux VM which has been configured such that it can run images of other architectures through Qemu user mode emulation. You can configure native linux in a similar way and it too will then run ARM images. There is a well written three part series that describes it all in detail
Main thing to take away from Part#1 is that any file on Linux is executed through an interpreter (even binary files). The choice of interpreter is configurable, through binfmt_misc, based on byte patterns at the beginning of file or filename extension etc.
Part#2 builds on Part#1 to show how to configure Linux kernel (installed on any architecture) to interpret ARM binaries using Qemu User Emulation.
Finally Part#3 shows how to apply the same trick this time to a linux setup in a docker container which means that linux docker container (which could be for any architecture) will be able to execute ARM binaries.
Important thing to note here is that there is nothing special about docker implementation or containerization that allows docker on Windows to be able to execute ARM binaries. Instead any Linux setup (whether on bare metal or in a container) can be configured to execute ARM binaries through Qemu's user mode emulation of an ARM cpu.
I know this post is old but I will post my solution here in case someone came here through Google.
This happen because your Docker host is not able to run images with AMR architecture. To be enable this in your Docker just run:
docker run --rm --privileged hypriot/qemu-register
More info you can find on this post.
You need the kernel configured for qemu's binfmt_misc module, and the container needs to have the static binaries used by qemu available inside the container filesystem.
You can load the files on the host with the hyperiot/qemu-register image, however I prefer the distribution vendor packages when available (ensures that I get patches when I update). For Debian, the imporant packages is qemu-user-static which you can install as root with:
apt-get update && apt-get install qemu-user-static
Ensure the kernel module is loaded (as root):
modprobe binfmt_misc
Then when running the container, you can mount the static qemu binaries into your container rather than packaging them inside your image, e.g. for the arm arch:
docker run -it --rm \
-v /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static:ro \
hypriot/rpi-node /bin/sh
Docker includes binfmt_misc in the embedded Linux VM's used on Docker for Desktop, and there appears to be some additional functionality to avoid the need to manually mount the static qemu files inside the container.
I've very simple theoretical questions. We used Docker in VirtualBox before Docker Desktop for Windows and Mac OS launched officially. In Virtual Box, we get a VM and we manage it using docker-machine command whereas we usually don't use docker-machine if we use Docker Desktop for Windows and Mac OS. Now keeping in the view of both versions:
What is Docker Host and What it does in Both Versions?
Docker Client is now referred as any terminal on Windows if we use Docker for Windows? (Do we now not need to configure our terminal as Docker Client to manage our containers?)
Are the Docker Engine and Docker Daemon the same or different things in both versions?
What is the role of MobyLinux VM in Hyper-V in Windows?
How Docker isolates our application from the Host OS?
Any help will be appreciated.
The docker host is where your containers run. As docker containers need to run under linux, if you're on a mac or windows you can only run them locally on your machine if you have a linux vm running.
On VirtualBox, the docker host is an instance of boot2docker, which is a very lightweight linux. On docker4mac, the host is effectively your mac (each container actually runs under a "micro linux" called xhyve, but that's for the details)
A docker client is simply any terminal that runs the Docker Client application, which is a CLI application that communicates with a Docker Daemon running inside the host.
As far as I understand, the Docker engine and docker daemon are the same even in Docker 4 mac/windows.
I don't know about MobyLinux
Container isolation from the host (and other containers) is achieved using namespace, cgroup and private networks. See https://docs.docker.com/engine/security/security/ I however don't believe that security like cgroup are enabled by default.
All good questions...
Regarding to Docker Daemon, Docker Engine, Docker client, Docker host, and how Docker works, please refer to Understanding Docker doc and Docker Engine page. There have clearly architecture structure and explanation.
For question 4, Docker should runs in Linux, so Docker for Windows will create a Linux "MobyLinux" VM to run Docker components.