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

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.

主站蜘蛛池模板: 香港 | 甘南县| 商丘市| 昌图县| 海门市| 巴林左旗| 嘉兴市| 天津市| 双江| 威远县| 南靖县| 大化| 田东县| 时尚| 潍坊市| 昌江| 巨鹿县| 临夏市| 大竹县| 盖州市| 建德市| 长岭县| 南阳市| 吉首市| 茶陵县| 宾阳县| 淮阳县| 威海市| 偏关县| 宜川县| 龙口市| 福海县| 瑞安市| 涪陵区| 南乐县| 金阳县| 阜平县| 静海县| 葫芦岛市| 河间市| 建昌县|