Understanding Step By Step Docker Basic

Lawson Borges
By -
0

 Understanding Step By Step Docker file. Below is the guide on how to run the docker.


Step to run 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."


 If it appears in the search results, Hyper-V is installed. If it doesn't show up, you'll need to enable it through the Control Panel.

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.
  1. FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build  
  2. WORKDIR /myreleasefolder  
  3. # copy csproj and restore as distinct layers  
  4. COPY *.sln .  
  5. COPY Dockertest/*.csproj ./Dockertest/  
  6. RUN dotnet restore  
  7.   
  8. # copy everything else and build app  
  9. COPY Dockertest/. ./Dockertest/  
  10. RUN dotnet publish -c Release -o out  
  11.   
  12. FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime  
  13. WORKDIR /myreleasefolder  
  14. COPY --from=build /myreleasefolder/out ./  
  15. 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 




Tags:

Post a Comment

0Comments

Post a Comment (0)