How to enable mixed platform on Docker on year 2022? - docker

I checked out some tutorials but the Daemon tab is already missing with the current version of Docker Desktop(4.8.1). Under the "Docker Engine" tab, I set the 'experimental' field to 'true' but it looks like it is still not working.
The "platform" parameter isn't working.

What works:
Running linux based containers, Switch to Windows containers... and
run windows containers. Running containers will keep on running. You'll find it on right-click on system tray
of Docker Desktop.
Pull windows and linux based containers in Windows mode, but NOT in linux mode
Creating a compose file and use the keys platform: linux and platform: windows mixed, while running Windows container mode. Compose will choose the daemon for you.
You can not:
Build images on a daemon not supporting the OS of the image, see Roadmap
I don't know whats wrong in your case. In Windows Mode with
{
"experimental": true
}
(you have to set it again in Windows Mode, there are 2 different daemon settings)
you should be able to pull linux and windows images. Just checked with docker desktop 4.9.0 (prebuild), can't pull in 4.8.1 due to bug in proxy settings..

Related

how to change Docker server host configuration from Linux to Windows?

I am new to Docker and I am trying to setup and build docker image on my local Windows 10 machine. I created a simple .Net program and added Docker support to it. I also installed Docker Desktop on my machine. When I load my project with VS.Net 2019, I got the following error message: "A non-critical error occurred while getting containers ready. Your project will continue to function normally. The error was: Your Docker server host is configured for 'Linux', however the docker-compose project targets 'Windows'". My question is - how do I change my Docker server host configuration from Linux to Windows?
I'm assuming you have Docker Desktop deployed on your host - you can change between Windows and Linux containers by selecting the Docker icon from the icons tray, and click the option to switch:

Change the container OS for docker in Windows Server 2022

We have an install of Windows Server 2022 and want to utilise the built in Docker that comes with it. Is there a way to change the container OS when performing a docker build so that it uses Linux containers.
This is possible in Docker Desktop running on Windows 10 by right clicking the docker icon in the system tray and selecting "switch to windows/linux containers". Is this possible to do in Windows Server 2022?
Thanks

Is it not possible to run Linux and Windows docker containers simultaneously?

Based on Microsoft's documentation, in order to run a Windows containers:
If you see an error message that says no matching manifest for linux/amd64 in the manifest list entries, make sure Docker isn't
configured to run Linux containers. To switch to Windows containers in
Docker, right-click the Docker icon, and select Switch to Windows
containers. To use the command line to switch between containers, run & $Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon.
This seems problematic (I just tried it and got the error mentioned) since I want to run a test lab with Windows and Linux boxes interacting on a network. Is docker not capable of this or have I perhaps misunderstood something?
It is possible to run Windows containers and Linux containers. The only drawback is that you cannot manage (e.g. start, stop) Windows and Linux containers at the same time without switching.
If you select "Switch to Windows containers", you get this message:
You are about to switch to Windows containers. Existing containers will continue to run, but you will not be able to manage them until you switch back to linux containers. No data will be lost otherwise.
Do you want to continue?

Teamcity - Unmet requirements: docker.server.osType contains windows

I installed Docker Desktop 2.0.0.3 on my Teamcity (build 61245) Build Agent and restarted the Build Agent/Server, I've also switch to run Windows containers but I am still getting
Unmet requirements: docker.server.osType contains windows
Is this something I need to manually setup?
Docker plugin is installed and enabled by default in this build of Teamcity.
This might be a Teamcity bug where the docker.server.osType is not being set when running windows containers in Docker Desktop for Windows (Windows Server 2016).
My original setup, I had Docker running Windows containers in my Teamcity Server/Agent machine running Windows Server 2016. I was expecting to use Docker Wrapper and run Docker image platform set to Windows (I realized that would not work with the node image since that is built under the Linux platform). However, my docker.server.osType should still be set to windows regardless and I should have passed the compatibility check.
What I did to get around this was to run linux containers in my Windows Server 2016 machine. Below are the steps I took to address this issue.
In the build agent, Docker Settings -> Daemon -> Check Experimental Features
In the builder server {TeamCityDirectory}\conf\teamcity-startup.properties -> add teamcity.docker.lcow.enabled = true
Switch docker to run linux containers
After doing that, I restarted my Build Agent and Build Server services, and the docker.server.osType in my Build Agent popped up to with value of linux. I then set my build step's Docker image platform to linux.

Docker and specifying a target OS

I've read that:
Docker is a system for management and deployment of application containers, not operating system containers.
However, in several resources (e.g. around 1:20 into https://www.youtube.com/watch?v=pGYAg7TMmp0) it gives an example of "problems" you might encounter if you've developed a web application on a Windows PC or Mac, and are deploying it to a Linux server.
So, how does Docker help in this situation? If we take a web application I understand Docker could help you make a container with the source, and say a specific version of PHP. But could you specify a target OS for it to run on, if it's different from the server that Docker is running on?
The Docker FAQ (https://docs.docker.com/engine/faq/) says
You can run both Linux and Windows programs and excutables in Docker containers.
Does this mean you need Docker installed on a Linux and Windows machine separately to do this, or is it possible to specify any OS within your Docker image and have any machine run it?
Please can someone explain how - or if - Docker deals with specifying a particular OS for your application?
Docker started as a way to run containers on Linux hosts, and this remains the dominate target for docker containers. Developer environments include an embedded VM to run Linux under the covers on Mac and Windows. Originally this was VirtualBox, but newer releases use xhyve and hyperv. The host OS in all of these are Linux so you are not building your image on one OS and running it on another OS.
Since that start, Docker has expanded target OS's. This requires that you have a docker installation for that OS, and it requires that your image be designed to run on that architecture/OS. This started with other architectures of Linux like arm64, and now zLinux. The Microsoft partnership is a rather large rewrite, partially in Windows itself, but also in the Docker code, and especially in the images designed to run natively on Windows. To run these, you have to change the settings on Docker for Windows to run Windows containers instead of Linux containers, you cannot run them both concurrently on the same host. At present, running Windows binaries can only be done on a Windows host, Microsoft isn't shipping free VMs for Linux hosts. And as a new target platform, it still lags behind in features from the Linux hosts.

Resources