Microsoft have announced the availability of SQL Server 2017 RC1 and I wanted to check it out in a container however it seems that the Windows image hasn’t been updated on the Docker Hub: –
But no matter, running Docker on Windows 10 gives me the option to run Linux containers and the SQL Server 2017 RC1 Linux container image is available on the Docker Hub: –
This post is a step-by-step guide to getting Linux containers running on your Windows 10 machine. The first thing to do is install the Docker Engine.
Installing Docker on Windows 10 is different than installing on Windows Server 2016, you’ll need to grab the Community Edition installer from the Docker Store.
Once installed, you’ll then need to switch the engine from Windows Container to Linux Containers by right-clicking the Docker icon in the taskbar and selecting “Switch to Linux Containers…” : –
The way Linux containers run on Windows is that they run in a virtual machine, you can see this by opening up Hyper-V Manager: –
Now the linux image can be pulled from the Docker Hub. To search for the image run: –
docker search microsoft/mssql-server-linux
To pull the image down: –
docker pull microsoft/mssql-server-linux:rc1
The first thing I noticed when I did this was, how quick was it to pull the image down? If you’ve pulled the SQL Server Windows images down you’ll know that it takes a bit of time. The Linux image is significantly smaller than the Windows image (1.42GB compared to ~12GB), no idea why that is tbh.
Anyway, a container can be run once the image is down: –
docker run -d -p 15789:1433 --env ACCEPT_EULA=Y --env SA_PASSWORD=Testing1122 --name testcontainer microsoft/mssql-server-linux:rc1
N.B. – both the ACCEPT_EULA and SA_PASSWORD environment variables need to be upper case for the values passed to be accepted. Linux is case sensitive!
To confirm the container is up, run: –
docker ps -a
Hmm, something’s gone wrong for me: –
I need to view the container logs in order to find out what’s happened: –
docker logs testcontainer
Oh, the VM that the container is running in only has 2048MB of memory available!
Don’t adjust the memory allocation in Hyper-V Manager however, the changes won’t persist. Instead right-click on the Docker icon in the Taskbar and choose Settings then Advanced: –
The Docker Engine will restart to apply the changes, which can be confirmed in Hyper-V Manager: –
And now the container can be started: –
docker start testcontainer docker ps
Cool, the container is up and running! Connecting locally is different than connecting to a SQL instance in a Windows container. With Windows containers I would use the docker inspect command to find the private IP address assigned to the container and use that to connect via SSMS.
However with linux containers we use the host’s IP address/name and the port number than was specified upon container runtime: –
Enter in the sa password that was specified and: –
SQL Server 2017 RC1 on Linux running in a container on Windows 10!
I think that’s pretty cool 🙂
Thanks for reading!
2 thoughts on “Running Linux Containers on Windows”
Do we read into the Linux image being ready first or is it just luck of the draw? ☺
From the conversations I’ve had about containers, it seems that MS will be working on the linux images first and then porting over to windows