We are going to discuss the Docker step-by-step

Agenda

Docker overview

Docker file overview

Sample .NET Core Web Application Docker File

#Comment
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app

EXPOSE 443
EXPOSE 80 

# copy project csproj file and restore it in docker directory
COPY ./*.csproj ./
RUN dotnet restore

# Copy everything into the docker directory and build
COPY . .
RUN dotnet publish -c Release -o out

# Build runtime final image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build /app/out .
ENTRYPOINT ["dotnet", "ProductMicroservice.dll"]

Commands to create a docker image

Conclusion

Here we have discussed the basics of docker and details about the docker file the and set of instructions we mostly use inside that while creating a docker image.

Happy Learning!