Docker on Windows: DockerFile

Once you are up and running with Docker on Windows… it is great! That’s an aside. Back to the job in hand.

So far, I have instantiated Containers from Images. I now wanted to play with DockerFile, which allows you to create Images. I briefly played with the Docker linux examples… but of course you have to get a bit twisted to make those work on Windows. I then went the Windows route, and followed these examples.

The key command is, imho:

docker build -f DockerFile .

Note that VSCode understands that this is a DockerFile:



The code and PowerShell execution is from this DockerFile:



Docker on older Windows: don’t bother

I have a working Windows Server 2016 with Containers Azure VM running Docker for Windows very successfully. As I could not resist, I started a Windows Server 2016 without Containers Azure VM, to see if I could get the Docker instructions for older Windows machines to work. (I had previously tried to get it running on my Windows 10 Anniversary box, and failed).

These are the links:

These are the screenshots, ultimately ending in failure. I started out with a 2 core/SSD box. I saw that unlike with the Azure box with Containers, predictably, there was no Docker entry in services. Things seemed to be going OK.. until the failures at the end.Conclusion: it is not worth the pain of installing Docker on a box that does not already have it available as a service… unless you enjoy going through the pain to get the reward. Part of the problem for me is that apart from my rubbish home laptop, I only have virtualised environments, and the Docker installation process is not expecting that.


Docker on Windows: First Steps

Last night I wasted a few hours getting nowhere: various problems with the spec or config of machines I was trying Docker out against not matching up to assumptions in the msdn pages, blogs I was reading. However, remember this is firmly Windows. Sure, I dare say it is a breeze on Linux – I would not know.

Tonight in fact was a much better contrast. I have any number of SQLServer instances running on a single Windows Server 2016 Azure VM.

Let’s take it real slow… The first important step is to grab the right image in Azure for these purposes. One that works is this:

Always select the Resource Manager deployment model:

This is the size I usually pick: shut it down between use and it won’t be too expensive. I would not useĀ 2 cores – I tried one a couple of days back, and it was REALLY slow. This speed is fine, for me:

That takes no more than 10 minutes to create.

Once it has been created, rdp onto it, and you will see that the Docker service is already running:

Then start a PowerShell admin session, and start playing. You will find there are already some images there:

docker images

Try these commands as well:

docker --help

docker --version

Across the Cloud of course the file transfers are blindingly fast – pulling down 10GB images is done in a matter of minutes, so this lot took me a max of minutes I think:

To get a new image, for example the latest SQL Server for Windows (as opposed these days to Linux, for example):

docker pull microsoft/mssql-server-windows

With that downloaded we can start the SQLServer instance:

docker run -d -p 1433:1433 -e sa_password=$dbpw -e ACCEPT_EULA=Y microsoft/mssql-server-windows

How to connect to the SQLServer instance

Run docker ps, and that gives you the Container Ids of all the running Docker… Containers:

docker ps

Stick that container id in a variable for later use, and run the inspect switch to get the ip address of the container..

docker inspect -format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $containerId

I could not see how to get the ip address directly into a variable, so again you have to do that by hand, e.g.


Now test your connectivity with sqlcmd before trying through ssms:

Now see my recent post on SSMS installation, and you see that what you created through the command line now appears in SSMS:

And finally for now shut down the container. In this shot, I try to stop a nonsense container, just to see how failure looks, and then stop the actual container. However I’d like better feedback than that (see the 2 docker stop lines). The second one has presumably silently failed. Trying to run sqlcmd against that ip address now fails… as you would want and expect. And although not shown, [docker ps] returns an empty set.



I don’t yet know how to run many containers against a single image, but this suggests to me it is possible.

Docker on Windows

Mostly the screenshots from an ultimately failed attempt to get Docker for Windows running on a) my local I3 Windows 10 Anniversary laptop, b) an Azure W10 Anniversary VM, c) an Azure Windows 2012R2 server. I might try again but right now PowerShell might be the better way to go for my use-cases.