Docker +Core3.0

// View Mirror 
    Docker ImagesRF Royalty Free 
// View container 
   Docker PS 
 // View container file 
sudo the Inspect 44fc0f0582d9 Docker 

Docker System df command, similar to the df command on Linux, for view disk usage of Docker

 

 du -hs / var / lib / docker / command to view disk usage

  

 

 

 Clean up all Dock is not currently running

  docker system prune

 

 

 docker system prune -a command to clean more thoroughly, you can not use the container Docker image are deleted. Note that these two commands will take you temporarily closed containers, as well as temporarily unused Docker mirrors are deleted ... so before you use must think about it .. I have not used, because there is no clean-up will open Docker image

 

 

 

  Stop docker service.

systemctl stop docker

Start docker service.

systemctl start docker

.Net Core 2 new projects, copy it to the directory linux environment

 

 

 Into the directory cd / WebApp (case-sensitive)

New Dockerfile file, touch Dockerfile

we Dockerfile

FROM mcr.microsoft.com/dotnet/core/sdk:3.0 As build // selected here dotnet version 
WorkDir / app // New working directory, there is actually a temporary directory 
Copy * .csproj ./ // copy the current folder csproj files in the / app working directory 
run dotnet restore // restore nuget package of projects 
cOPY. ./ // copy the current project folder [directory] file to take the working directory / app, the first point. represents the current the directory where the project, and the second represents the working directory ./ [directory] is actually a temporary 
run dotnet publish -c release -o out // use the command to publish the file under the / app / out back to the root directory [directory can use find - Find a name out] 
------- here only run half, can look at operating results,
perform docker build -t webapp [Note that the last point and spaces] format:. docker build -t [image name, such as webapp : 2.0] space.

 

 

 

Published catalog:

View catalog

 

 

 

Then supplement produced half of the mirror

AS Runtime mcr.microsoft.com/dotnet/core/aspnet:3.0 the FROM  
WORKDIR / App // set container's directory
COPY --from = build / app / out . // Copy the file to the release of the vessel above the working directory , pay attention to the back. 
EXPOSE 9999 // set container's listening port
ENTRYPOINT [ "dotnet", "WebApp.dll "] // start the application

Complete file:

[root@iZ2ze6qstyvxjb86krvizoZ WebApp]# vi Dockerfile

FROM mcr.microsoft.com/dotnet/core/sdk:3.0 As build
WorkDir /app
Copy *.csproj ./
run dotnet restore
COPY . ./
run dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime
WORKDIR /app
COPY --from=build /app/out .
EXPOSE 9999
ENTRYPOINT ["dotnet", "WebApp.dll"]

Execution docker build -t webapp. Next is the long wait .....

Create a container and start

docker run -d -p 9999: 9999 --name webapp webapp format: docker run -d -p external ports []: [interior of the container port, i.e. EXPOSE 8888 or ENV ASPNETCORE_URLS http://0.0.0.0:8888 ] - the webapp [in lowercase, container name] [the webapp previously generated image name, must be lowercase]

 

 

 

 

  





























Guess you like

Origin www.cnblogs.com/hnzheng/p/12629898.html