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

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.
主站蜘蛛池模板: 常熟市| 四平市| 高唐县| 疏勒县| 本溪市| 黑河市| 平山县| 北辰区| 康定县| 普陀区| 长治市| 巧家县| 兴城市| 阿拉善右旗| 左云县| 兰州市| 老河口市| 上栗县| 井陉县| 苍山县| 盘锦市| 西充县| 岱山县| 闽清县| 银川市| 肇东市| 桃源县| 古交市| 邵武市| 永寿县| 阿鲁科尔沁旗| 兴海县| 南昌县| 衡南县| 乐山市| 新民市| 长汀县| 虞城县| 敦煌市| 唐海县| 承德市|