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

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.

主站蜘蛛池模板: 茂名市| 右玉县| 阳原县| 中宁县| 石家庄市| 璧山县| 邻水| 百色市| 贵州省| 丽江市| 上林县| 东平县| 长海县| 盐池县| 青川县| 青岛市| 万山特区| 鄱阳县| 白水县| 恭城| 洱源县| 峡江县| 潞城市| 永川市| 鲜城| 宝丰县| 碌曲县| 奉化市| 武城县| 阳朔县| 赫章县| 科技| 丹阳市| 东兴市| 于都县| 吉木萨尔县| 利辛县| 祁东县| 陇川县| 浦县| 南平市|