- Learning Windows Server Containers
- Srikanth Machiraju
- 524字
- 2021-07-02 23:23:27
Pulling images from Docker Hub
In this section, we will use an existing Docker image to create a new container. Docker Hub is a public repository for storing Docker images. Docker images can be made up of Linux base OS or windowsservercore OS. Since OS kernels are completely different, containers made up of Linux cannot be installed on Windows and vice versa. At this point we cannot differentiate by looking at the name if the base OS is made up of Linux/Windows.
If you try to install or pull a Linux image on Windows, it might fail with an error as follows:

Microsoft has also published a few docker images starting with microsoft/ that are made up of both Linux and windowsservercore base. Follow these steps to search and create a new container using a windowsservercore-based image called microsoft/iis:
- Run the following command to search images starting with microsoft:
docker search microsoft
This will list containers containing the word microsoft, as shown in the following screenshot:

- Now let's try pulling an image called microsoft/iis, which is a Windows Server Core image with windowsservercose as base OS image and it comes installed with IIS web server. Run the following command to pull the image on to the container host:
docker pull microsoft/iis
The docker pull command is used to download the images from remote repositories. By default, Docker will search for images on Docker Hub. Once downloaded, Docker maintains a local cache of images:

- Now if you list the local images by typing docker images, you should see the microsoft/iis image alongside the other base OS images, as shown in the following screenshot:

- Now let's create a new container using the above image. Run the following command to create a new container using microsoft/iis:
docker run -t -d -p 80:80 microsoft/iis cmd
docker run can be used to create a new container using an image that is locally available. Docker tries to download the image from the public repository if it is not found locally. The following are the parameters of the preceding command:
- -t: This switch is used to let Docker enable a pseudo terminal for this container.
- -d: This switch lets Docker know to run the container in detached mode. By design, Docker containers running in detached mode exit as soon as the parent process used to create the container exits.
- -p: This switch is used to configure port mapping from the container host to the new container.
- Now if you try to reach port 80 of the container host, you should be able to see the default home page of the IIS, as shown in the following screenshot:

- You can also check the container running by calling the following command:
docker ps -a
This shows the running containers:

Hurray! We have successfully created a new container. The new container is running on port 80 (PORTS section) and it is named randomly as elegant_kowalevski by Docker Engine. Docker assigns a unique ID, c8ee2696da3b, for every container; both the ID and names can be used to interact with a running container. We will see more about managing containers in our next chapter.
- Linux設備驅動開發詳解:基于最新的Linux4.0內核
- Linux運維之道(第3版)
- 鴻蒙生態:開啟萬物互聯的智慧新時代
- WordPress Mobile Web Development:Beginner's Guide
- Windows Server 2012 Hyper-V Cookbook
- 嵌入式Linux驅動程序和系統開發實例精講
- Installing and Configuring Windows 10:70-698 Exam Guide
- Linux內核設計的藝術:圖解Linux操作系統架構設計與實現原理
- Linux軟件管理平臺設計與實現
- Learning BeagleBone
- Advanced Infrastructure Penetration Testing
- Linux 從入門到項目實踐(超值版)
- 電腦辦公(Windows 10 + Office 2016)入門與提高(超值版)
- Linux從入門到精通
- 分布式實時處理系統:原理、架構與實現