Understanding Step By Step Docker file. Below is the guide on how to run the docker.
1) To verify whether Hyper-V is installed on your Windows system, you can navigate to the Windows search and look for "Hyper-V Manager."

after Enabling it restart your PC .
2)Create a Project. for demo purposes, i will create a .net MVC project with the name DockerTest.
3)Create a Docker file in solution manually with name Dockerfile. And add the below contain to make an Image file.
- FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
- WORKDIR /myreleasefolder
- # copy csproj and restore as distinct layers
- COPY *.sln .
- COPY Dockertest/*.csproj ./Dockertest/
- RUN dotnet restore
- # copy everything else and build app
- COPY Dockertest/. ./Dockertest/
- RUN dotnet publish -c Release -o out
- FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime
- WORKDIR /myreleasefolder
- COPY --from=build /myreleasefolder/out ./
- ENTRYPOINT ["dotnet", "Dockertest.dll"]
4)Docker Contains 2 major component
a)Docker image
b)Docker Container
to add an image you can go to the root directory of the project and run CMD. In cmd, you need to add below line
docker build -t aspimage .
and to run the image you need to add below line in CMD
add docker run --name aspcontainer -d -p 8080:80 aspimage
docker build -t aspimage .
and to run the image you need to add below line in CMD
add docker run --name aspcontainer -d -p 8080:80 aspimage

.png)
Post a Comment
0Comments