Understanding of Dockerfile and its commands?
We have used Docker images to create containers and we pull the images from Docker Hub to create containers. But in this article, we will see how docker images are creating and what commands are using as part of this process. Docker can build images automatically by reading the instructions from a Dockerfile . A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Think of it as a shellscript. It gathered multiple commands into a single document to fulfill a single task. build command is used to create an image from the Dockerfile. $ docker build You can name your image as well. $ docker build -t my-image If your Dockerfile is placed in another path, $ docker build -f /path/to/a/Dockerfile Let's first look at below Dockerfile and see those commands. FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build WORKDIR /src COPY MyMicroservice.csproj . RUN dotnet restore COPY . . RUN dotnet publish -c release -o /app FR