Woot. You’ve made it to Part 3. This is probably going to be the best part so far. Mostly because it’s only the third part. At this point, you should be running Docker and be in Windows Container mode. Let’s make a container!!!!!1111 Pump the brakes, Space Cowboy!
First we’re gonna need an Image. What’s an Image? If I were to throw this at the Sitecore Analogy 8-ball, and shake vigorously, I’d get a response back like this:
An Image is like a Sitecore Template. It has properties and can even inherit other Images. It’s used as an object to create Containers.
Me, About 30 minutes ago
OK, so that’s great. What about layers? What do they do? Layers are about re-usability. An image can actually be used in more than one child Image. For example, if you had a CD Image and a CM Image, you could (and do) use the same Sitecore Base Image. Whoa. Eventually, you’re going to get into a pretty neat dependency tree with your images…orrrrr you rely on someone else to conquer that. I’d look at the latter, personally. Like the guys over in the Sitecore slack channel #docker. So now you know that images are like templates, and the concept of layers allows for pretty darn-reusable images. Great. What’s even better, some images are available online already! For free! What a time to be alive!
Let’s grab our first Image, a foundational layer in our solr container. It’s called Nano Server, and you can read a little about it here. Essentially it’s an ultra slim Windows OS. Which, for solr, should do just fine. Let’s pull it from the Microsoft Container Registry (mcr) with the following command in PowerShell:
docker image pull mcr.microsoft.com/windows/nanoserver:1903
Wait. What the hell is 1903? That’s your windows Release Id. Basically what version of windows you have. What version do you have? You can find out with the following PowerShell command:
(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ReleaseId
I was greeted with a friendly “1903” which made me feel good, since it was the same value last week. NOTE: If you are running at LTSC version of Windows 10, you likely need to look into the ltsc Images. Your IT peeps can likely tell you if you’re on LTSC or not.
ALL DOCKER IMAGES NAMED ARE GOING TO USE THIS RELEASE ID. REMEMBER IT!
After running the docker image pull comand, you’ll see some text like this go by:
Cool, we’re good now. If you’ve executed the docker image pull command, you’re going to see a bit of activity, some downloading, some expanding, hopefully no red error messages.
Now if you run the following command to list out your docker images
docker image ls
You should see something like this:
Congrats you now have your first Docker Image. Celebrate. Maybe more Crown. Or just fistpump. You do you. While I’ve got you here, let’s snag a couple more base images we’ll need:
docker image pull mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-1903
docker image pull mcr.microsoft.com/windows/servercore:1903
The “servercore” image is pretty hefty at around 2.2GB. It’ll take a bit. aspnet:4.8 is a little more reasonable since it uses some of the base images in servercore. Patience, Grasshopper. Here’s what you should see with a docker image ls:
Next up, let’s add a little layered goodness here. This is going to be a foundational Image. We won’t ever run it directly, but we’ll use him as a base layer in many other images. How do you even go about doing that? Simple. We’re going to move to Step 4: Composing an Image
The TL;DR
#Get your release ID, and use it in the future calls throughout the process
(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ReleaseId
#Pull base images
docker image pull mcr.microsoft.com/windows/nanoserver:1903
docker image pull mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-1903
docker image pull mcr.microsoft.com/windows/servercore:1903
This is a post in the “Yet Another Sitecore Docker Series.” Other Posts include
- Part 1: The Beginning
- Part 2: Running Docker
- Part 3: Layers are Yum
- Part 4: Composing an Image
- Part 5: Deconstructing a Dockerfile
- Part 6: Simply Solr
- Part 7: Smooth as SQL
- Part 8: It’s Sitecore Time
- Part 9: Compose all the Things