
上QQ阅读APP看书,第一时间看更新
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:
- Use the Ctrl + Shift + P shortcut in order to open the Command Palette.
- 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>
- 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 3, Working 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:
- 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
- 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.