We have learned about building Windows Container images using Docker image files and also using Docker build. However, we have not yet learned how to build them efficiently. This section deals with important tips and tactics which can be used to optimize the image-building process. Before we learn to optimize a Dockerfile, let us first understand how Docker builds images.
The following Dockerfile creates a Windows image with IIS installed:
FROM Microsoft/windowsservercore RUN dism /online /enable-feature /all / featurename:iis-webserver /NoRestart RUN echo "Hello World - Dockerfile" > c:\inetpub\wwwroot\index.html EXPOSE 80 CMD [ "cmd" ]
Docker consumes the above Dockerfile and, at the first instruction, where we select the base image Microsoft/windowsservercore,
a temporary container is created. Thereafter at every instruction Docker updates the container and creates another temporary container which will be used by the next instruction. In...