官术网_书友最值得收藏!

Preparing a Windows Containers image

A Windows Containers image can be developed primarily in two ways: using PowerShell commands or by using Docker CLI commands. Every Windows Server Container or Hyper-V Container should be created from a base OS image. Windows Server 2016 TP5 comes with two types of base OS images, windowsservercore and nanoserver. The Windows Server we created on Azure comes with windowsservercore installed by default. You can install the nanoserver image by running the following command:

    docker pull microsoft/nanoserver

In this chapter, we will use Docker commands to create a Windows Containers image from scratch, which will host default index pages on the IIS web server. First let's check for base OS images installed on our containers host:

    docker images

The preceding command will give the following output:

windowsservercore is the base OS image used in the Windows Containers world and it forms the bottom-most layer of a container. As you can see, the image is still heavy on size with 7.75 GB. This additional size hurdle is overcome by a special type of server image called nanoserver images. For now, we will only use windowsservercore.

If you do not find any image on your container host, you can pull the image from Docker Hub by running the following command:

    docker pull microsoft/windowsservercore

If you want to search the repository, use docker search to get a list of all container images available.

You can list the number of containers running, exited, or paused on any host by using the following command:

    docker ps

The preceding command will give the following output:

As you can see, running docker ps lists the containers and the corresponding image names, status, and so on. The following list explains two methods that can be used to create windows server images:

  • Since containers are layered systems, we can start with creating a new container using the base OS image, start customizing the container as per your needs using PowerShell or Windows CLI, and once you are done convert it into an image. Though this sounds simple, this is not quite often how we develop containers. Since we do not maintain a list of steps executed before creating an image, this method is more error prone and not recommended for production scenarios.
  • The second and the most preferred way is to write the instructions to prepare an image in a special type of file called Dockerfile. Dockerfile is a set of instructions that follow Docker semantics and they are compiled by Docker Engine while preparing the image. Since we are documenting our configuration as code, it can be easily incorporated in continuous integration or deployment practices.
主站蜘蛛池模板: 密云县| 桃江县| 金乡县| 古蔺县| 林州市| 札达县| 垣曲县| 哈巴河县| 临澧县| 五家渠市| 九龙县| 大理市| 密云县| 和龙市| 鹿邑县| 施秉县| 平南县| 延安市| 新密市| 新津县| 贡山| 临清市| 左贡县| 浮山县| 琼中| 玉树县| 临泽县| 洞口县| 礼泉县| 克拉玛依市| 年辖:市辖区| 天津市| 林芝县| 志丹县| 南宁市| 洪湖市| 静乐县| 北川| 江安县| 阳朔县| 都安|