Building and Tagging container image

Building and Tagging Container Images in Windows 2016

In this blog, we will show how to Building and Tagging Container Images in windows 2016 using docker command using PowerShell.

BUILDING NEW CONTAINER IMAGE USING CACHE

  • You need to use docker build command to building and tagging the container images. If you run the help you will find the below option.
Building and Tagging Container Images in Windows 2016
  • First,  Go to index.html and edit the file content as assistanz V2.
Building and Tagging Container Images in Windows 2016
  • Now build the image using the below command.
Building and Tagging Container Images in Windows 2016
  • Build ran extremely fast and completed successfully.
Building and Tagging Container Images in Windows 2016
  • You can notice the output it shows using cache underneath Step 2 & Step 3.
Building and Tagging Container Images in Windows 2016
  • This caching functionally is built-in with docker build process for building container images. It’s like re-using the settings that were done with the previous build to make things more efficient.
  • In Step-4, it actually copied our modified file to wwwroot folder inside the container image.
  • We can disable the cache using nocache option.
Building and Tagging Container Images in Windows 2016

TAGGING THE CONTAINER IMAGE

  • When we ran docker images command we can find two versions of container images named web.
Building and Tagging Container Images in Windows 2016
  • web V2 is the latest version, so we need to change the tag from V2 to latest.
  • First, we change the web latest to web V1 using below command.

docker tag web:latest web:V1

Building and Tagging Container Images in Windows 2016
  • Now it will show two images with same image ID.
Building and Tagging Container Images in Windows 2016
  • To remove the tag from the old image execute the below command.

docker rmi web:latest

Building and Tagging Container Images in Windows 2016
  • Now docker images command will show only the two container images.
Building and Tagging Container Images in Windows 2016
  • Also, make sure that you always use the latest tag for most recent container images. We just need to repeat the process which we did earlier.
  • We need to change the tag of web image from v2 to latest using below command.

docker tag web:v2 web:latest

Building and Tagging Container Images in Windows 2016
  • Now there will be two images under same image ID.
Building and Tagging Container Images in Windows 2016
  • Now remove the tag from the web v2 version using below command.

docker rmi web:v2

Building and Tagging Container Images in Windows 2016
  • Now we have only two images with V1 and latest tags.
Building and Tagging Container Images in Windows 2016
  • These tags will be used while creating the containers. For example.
Building and Tagging Container Images in Windows 2016
VIDEO

Thanks for reading this blog. We hope it was useful for you to learn how to tag and untag the container images.

Loges