Remote Windows Docker containers from a Linux machine? - linux

I have a Jenkins CI host server running on Linux machine and a Jenkins build node running on a Windows server. I'd like to start use the Docker containers for building, testing, packaging, and related artifact generation.
However, at the end of the day, I need to generate Windows binaries. Is it possible to create Windows Docker containers on a Windows server and connect to them on a Linux server?

Related

how docker executes windows container?

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

Running an msi from Docker. Which host OS should choose

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.

Is it possible to build a Linux docker image on VSTS 2017 Hosted agent?

I've got a Dockerfile that pulls from a base image of microsoft/dotnet:2.0-runtime. When I do a build locally (on windows running Linux containers) I get a Linux docker image.
however, if we run the same build process on VSTS using a 2017 Hosted agent then we get a windows docker image.
Is it possible to build a Linux docker image on VSTS 2017 Hosted agent without having to use a Linux build agent?
No, there is no way to build a Linux docker image with VSTS Hosted VS2017 agent. Hosted VS2017 agent can only build for Windows docker images.
The workarounds to build Linux docker image as below:
Build with Hosted Linux Preview agent
Build with private agent with your own windows machine

Windows Container vs Docker Container and Azure Container Services/Kubernetes cluster with Linux OS

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.

Jenkins deployment to windows

I want to automate deployment of my project from Jenkins on a Linux server to a Windows server. As I have read, there are some tools to scp from linux to windows. Is there a tool that I can use to push the build from linux using a script?
One solution should be to install a Jenkins slave agent on the Windows machine.
With this solution, you can create a dedicated job and launch it on the Windows node.
This job can get the artefact (or the build result) from the Linux server with the Copy Artifact plugin.

Resources