So now that you have installed Docker on your Windows Server 2022 system, let’s take a look at how to install and configure containers.
In Exercise 12.2, you’ll learn how to make sure your Docker service is started. I will then show you how to install a base operating system image onto your host and how to create Windows Server containers.
There are dozens of premade Docker images. You can look at all of the various Docker components at the Docker Store. Go to https://store .docker.com to see all the available Docker downloads (including premade images).
EXERCISE 12.2
Installing a Base Operating System
- Open the Services MMC by clicking Start ➢ Windows Administrative Tools ➢ Services.
- Scroll down until you see Docker. Make sure that the Docker Service has started (see Figure 12.5). If it hasn’t started, right- click Docker and choose Start.
FIGURE 12.5 Checking that Docker Service has started
EXERCISE 12.2
3. Close Services.
4. Open PowerShell with administrative privileges by clicking Start and right- clicking Windows PowerShell, then choosing More ➪ Run As Administrator.
5. Now we are going to see if any containers are running. To do this, type docker info in PowerShell and press Enter. You will see a report (see Figure 12.6) that will show you if you have any containers running.
6. So now we are going to install a container image for either Microsoft Nano Server or Windows Server Core from the online package repository. To begin, type one of the following commands into PowerShell (choose the command for the operating system that you want):
Docker pull microsoft/nanoserver docker pull microsoft/windowsservercore
7. After your container is installed, restart the Docker service. Type the following command into PowerShell: Restart- Service docker
8. Now let’s take a look at your Docker information again by typing docker info at the PowerShell prompt. As you can see, we now have an image that we didn’t have before (see Figure 12.7).
FIGURE 12.7 Checking Docker information
9. To see all the images that you have on your system, at the PowerShell prompt type docker images (see Figure 12.8).
FIGURE 12.8 Docker images
10. So now that you have seen how to grab a base image from docker, let’s create a Windows Server container with Nano Server installed. At the PowerShell prompt, type the following command:
docker run microsoft/dotnet- samples:dotnetapp- nanoserver
11. If the installation worked properly, you should see what looks like to be a small alien on your screen (see Figure 12.9). Type docker info at the PowerShell prompt and you will see that you now have a container. You will also notice that you have two images now: the one you downloaded earlier and the one you just downloaded.
EXERCISE 12.2
12. Close PowerShell.