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

Building a Docker image

Building a Docker image is performed using the docker build command. You have two options when it comes to performing this step:

  • Use Visual Studio Code's Command Palette.
  • Use the Powershell command line.

In Visual Studio Code, do the following:

  1. Use the Ctrl + Shift + shortcut in order to open the Command Palette.
  2. Search for Docker: Build Image and execute it by providing the image name and tag in the following format (or use the default suggested name based on the directory name):
<image name>:<tag>
  1. If you are logged into a custom registry or using Docker Hub, you can also specify the following:
<registry or username>/<image name>:<tag>
The concepts of Docker Registry and the public Docker Hub will be covered in Chapter 3Working with Container Images.

We will use the following image name and tag in this example: docker-helloworld-iis:latest.

The Visual Studio Code command is equivalent to performing the following actions in Powershell:

  1. Change the working directory to the folder that contains the Dockerfile; for example:
cd c:\src\Hands-On-Kubernetes-on-Windows\Chapter01\docker-helloworld-iis
  1. Execute the docker build command while specifying the -t argument in order to provide the image name and tag and use the current directory, ., as the build context:
docker build -t docker-helloworld-iis:latest .

The following screenshot shows the output of the preceding command:

After a successful build, you can use the docker-helloworld-iis local image to create new containers. We will cover this in the next subsection.

主站蜘蛛池模板: 灌南县| 伊川县| 文成县| 尼木县| 长乐市| 平塘县| 安泽县| 浙江省| 平湖市| 泗洪县| 阜阳市| 延川县| 西乌珠穆沁旗| 迭部县| 邯郸市| 白城市| 红原县| 兰西县| 巴南区| 昭平县| 边坝县| 分宜县| 松江区| 黄平县| 蒲江县| 古丈县| 甘泉县| 合水县| 靖宇县| 泸定县| 晋中市| 奉新县| 普安县| 巩义市| 高雄市| 松原市| 商丘市| 香港 | 克什克腾旗| 辽宁省| 清新县|