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

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.
主站蜘蛛池模板: 旌德县| 余干县| 确山县| 罗源县| 诸暨市| 新绛县| 河东区| 陕西省| 盱眙县| 麟游县| 南漳县| 定西市| 元谋县| 象山县| 望城县| 印江| 嘉黎县| 阿克| 塔河县| 陇川县| 侯马市| 江陵县| 盐津县| 衡阳县| 合江县| 临泉县| 阿拉善右旗| 仁布县| 梧州市| 隆德县| 苗栗市| 观塘区| 汽车| 响水县| 客服| 江达县| 错那县| 始兴县| 繁昌县| 四川省| 麻城市|