We have seen how to create images by committing containers. What if you want to update the image with new versions of dependencies or new versions of your own application? It soon becomes impractical to do the steps of starting, setting up, and committing over and over again. We need a repeatable method to build images. In comes Dockerfile, which is nothing more than a text file that contains instructions to automate the steps you would otherwise have taken to build an image.
docker build will read these instructions sequentially, committing them along the way, and build an image.
docker build command takes this Dockerfile and a context to execute the instructions, and builds a Docker image. Context refers to the path or source code ...