Run TFS with Docker - tfs

I've been reading a lot about Docker and its uses. Currently we are using TFS for building and deploying our in house app (.net c#). Are there any benefits for transitioning to Docker? Meaning having it set up so that after TFS runs the build, it will deploy to a container?
Currently there is no easy way to run the build ourselves besides doing bunch of manual steps: How to: Build Team Projects on a Desktop.
Can you run docker on Windows Server?
Would we be able to setup our VMs with docker so that we can deploy/mimic deployment process locally (to our vms)?
And have the same process set up for our production environment?

Yes, you can run docker on Windows Server, but it cannot run natively on Windows for now.
Because Docker relies on Linux-specific features, you can’t run Docker
natively in Windows. Instead, you must install the Docker Toolbox
application. The application installs a VirtualBox Virtual Machine
(VM), Docker itself, and the Docker Toolbox management tool. These
three things allow you to run Docker on Windows.
For the deployment with docker, refer to this link for details: http://www.colinsalmcorner.com/post/continuous-deployment-with-docker-and-build-vnext

In the meanwhile Microsoft has released their Windows Container feature within Windows Server 2016 and Windows 10 Pro and up. One can start running container natively on Windows. Mind you, you can only run Windows-based container images. So this cannot be leveraged if you want to run Linux-based container images, which currently is still the majority. Unfortunately at this moment one cannot easily filter within Docker Hub on the desired container-base.
Refer to https://learn.microsoft.com/en-us/virtualization/windowscontainers/

Related

Is it possible to run Docker Desktop with existing Linux VM?

I have an Ubuntu VM using Hyper-V, specialized for server development with Docker daemon and docker compose already installed on it; is there any way to connect Docker Desktop on the Windows machine to the docker daemon in the Ubuntu VM?
Well, if I'm understanding correctly, you can't really 'connect' Windows Docker Desktop to the Linux Docker daemon; but, you can use various methods to control both of the daemons, and also link them into a single 'unit'.
To control them, my favorite way is to use Portainer (including the Portainer Agent), and to join the daemons I personally created a Docker Swarm for my small home network of Docker daemons on various OS's (I currently have 1 on Win 10, 1 on Raspberry Pi, and 1 on Kubuntu).
Docker Swarm is from my understanding, fading away these days though, in favor of Kubernetes. In my use case swarm was just easier, and had all I needed, so I opted for it over Kubernetes; you'll have to feel them both out on your own for your preference.
As mentioned in the other answer, this isn't really possible in docker for windows. You should probably migrate from your VM to WSL2 anyway now. It'll only get harder in the future. If your work is in git then you just have to reclone your repos and rebuild/pull your images.
However, I use docker professionally every day and I don't see a need for docker desktop. Which suggests that you probably don't need it either. What is it really? A UI that shows you what containers are running? Big deal -- I have docker ps to do that in bash...
I use windows because I'm working on a number of windows projects for clients and dual-boot into Linux for a reality check when windows is driving me insane or whenever I'm not being forced to run windows. I do all my server development in my pure-ubuntu environment (using K3D).
I'm also thinking of dumping ubuntu -- because of 'snap' -- I find it every bit as irritating as windows and I've been looking for an alternative for some time. I only use 3 GUI tools: a browser, postman, and IntelliJ -- if it wasn't for them I'd just install alpine on my laptop and be done.

How to run Docker commands on remote Windows engine

I'm working on integrating Docker into our TeamCity build process so that I can create a task that runs a "docker build" to create an image from our code. Right now, all our build agents run on either Windows Server 2008 or Windows Server 2012, neither of which can run Docker. There's a chance we can get a license for one Windows Server 2016 build machine, but I'm wondering if there's a way to run Docker Engine on that machine while issuing docker commands from other build agents.
Here's what I've considered so far:
Docker Toolkit: This is a way to run Docker on legacy systems, but it spins up a local VirtualBox VM running Linux thus it can only run Linux containers. I need to be able to build and run Windows containers.
Docker Machine: This is a way to talk to a remote Docker engine. However, according to this open bug, it appears Docker Machine is only capable to talking to remote engines on Linux hosts due to security implementations; It's an old issue but I can't find any indication this limitation has been removed.
Docker itself uses a client/server architecture, but I couldn't find any documentation on how to talk to a remote engine without using something like Docker Machine.
Anything else I'm missing, or am I just pretty much out of luck unless we upgrade all our build agents to Windows 10 or Windows Server 2016?
You can start using the remote Windows Server 2016 instance from other build agents.
Docker allows to expose the Docker Engine (aka Daemon) via tcp. In that case and especially when the host is publicly reachable you should consider configuring authentication using client/server certificates. Details can be found in the official documentation at https://docs.docker.com/engine/security/https/, but you may find the Windows Server specific article at https://stefanscherer.github.io/protecting-a-windows-2016-docker-engine-with-tls/ more helpful.
Regarding your aspect of using a client to connect to a remote Docker Engine, please use the -H tls://<host>:<port> argument like described at https://docs.docker.com/engine/reference/commandline/cli/ (or see the example provided at https://stefanscherer.github.io/protecting-a-windows-2016-docker-engine-with-tls/#testtlsconnection).

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.

windows docker on vmwarevsphere

we use VMWare vSphere for VMs in our company.
To automatically create docker hosts we use one simple command:
docker-machine --driver vmwarevsphere .... vm params(cpu,memory,network,name, etc)
It automatically creates new VM machine in our VM cluster, installs docker and then we add it to swarm or create new.
Right now I need to create windows docker hosts to run windows containers.
Docker-machine installs boot2docker.iso after creating VM.
But instead I need VM with microsoft servercore or nano.
How do I do it?
Thanks a lot.
Anton
On a Windows machine with Docker for Windows installed you could run the following command to pull the official images for server or nanoserver
docker pull microsoft/nanoserver
or
docker pull microsoft/windowsservercore
I'm not exactly sure how you're automating this - are you using a dockerfile or docker compose?
Are you talking about setting up the Windows host that runs Docker engine? If so, Docker for Windows CE is meant to be desktop software so not recommended for server side workload. Also, Windows EE Server requires Windows Server 2016 or later. If you would really like to use Windows server core mode, Windows Server 1709 offers that. Still, it quite bit new, so you should not set high expectations just yet.
As per the instruction to install the engine, MS has this.
https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-windows-server
Or, equivalent one from Docker here.
https://docs.docker.com/engine/installation/windows/docker-ee/
you are talking about hosting a windows container on VMware vSphere? I don't think this is possible right now, may be in the future. I have no documentation or link to verify my answer but in our company we have a similar situation and use vSphere for VMs and Linux container and Hyper-V in parallel for VMs and windows container.

How to run Google Datalab locally?

How do I run Datalab locally when it requires Docker (and Docker Toolbox is not supported as documented here: https://cloud.google.com/datalab/docs/quickstarts/quickstart-local)? The Docker website says Docker requires Windows 10 Professional or Enterprise 64-bit, and most corporate environments don't run Windows 10.
Docker is highly preferred over Docker Toolbox, as its a simpler, self-contained installation, with simpler configuration (since you don't have additional virtualization software to deal with, as you do with Docker Toolbox - namely boot2docker and its underlying functionality). However if you have a setup to run docker on your end, you should theoretically be able to use that for running the Datalab docker container by adapting the instructions.
You do have the option of running everything on a GCE VM.
I was facing the same problem, what I found more comfrotable in the end is to install Ubuntu on Virtual Box. This is free and fairly easy, and from the virtual machine you can use all the Docker and the Google guide to run Datalab locally.

Resources