Windows Server 2019 and Containers
After a bit of noise around the October release of Windows 10 the corresponding server release, Windows Server 2019, was also removed from the download sites Microsoft provides. Just last week it was finally re-released and made available on MSDN.
"Whatever. This is IT Pro stuff and I'm a dev…"
Well, it is true that a lot of the new features in Windows Server 2019 is more aimed at infrastructure than development. There are however still a few things that you might be interested in as a coder as well. For instance the Docker and container support has been greatly improved upon.
The low-down on how to get Docker running can be found here:
https://blog.sixeyed.com/getting-started-with-docker-on-windows-server-2019/
Following the steps there you should be able to get to the test page as shown.
You know what else is neat with this integration? Docker integrates with Windows Firewall - this means that when you expose a port in Docker it is automatically opened for you - that I like!
You can find them in the firewall rules list with the "Compartment" prefix.
So, for the sake of argument, let's say you need to build a classic .NET app instead of .NET Core.
Step through the wizard in Visual Studio:
Check Enable Docker Compose support.
The wizard creates a dockerfile for an earlier Windows Server build, so modify the dockerfile to use the newest server bits:
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.7.2-windowsservercore-ltsc2019
ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .
Bring up the publishing wizard and go for the container registry option (new one or existing):
Pushing the image will take a little bit of time since it's not as space optimized as the smallest .NET Core images.
Since this is a private repo you will need to authenticate on the server. You could install the Azure CLI on the server and use az acr login to integrate with Azure AD, or you can use docker login provided you enable Admin user in the Azure Portal for the registry you're using.
Once you're logged in you can pull down the image and run it:
docker run --name dockerfull -it -p 4321:80 acrname.azurecr.io/fulldotnet:latest
That will throw you into interactive mode (which is fine for debugging, but not usually done in production).
Without further ado it is browsable (the container logs visible in the background):
It should be noted that although the default enables Windows containers it is also possible to run Linux containers:
/en-us/virtualization/windowscontainers/deploy-containers/linux-containers
Granted, it is not quite as smooth as on Windows 10, but then again if you're in the process of installing a Windows-based host now it's not for the lack of viable Linux alternatives.
It may not be the announcement of the year for the general developer, but I find it to be a nice addition to the toolbox.
Comments
- Anonymous
November 28, 2018
Thanks Andreas! Nice highlight of 2019 features.