How to deploy Asp.Net6 Core in docker under Linux CentOS
Editor to share with you how to deploy Asp.Net6 Core under Linux CentOS docker, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Project settings
Set the dockerfile property to "always copy"
Modify the dockerfile file to:
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR / web COPY. .EXPOSE 80 EXPOSE 443FROM base AS finalENTRYPOINT ["dotnet", "OneZhanMVC.dll"]
Ps: if there is no dockerfile right click on the project, click add and select docker support.
2. Project release
Right-click the project release (publish method: file system)
3. Project transmission
Use ftp to connect to the server to transfer the published file to linux
4. Install docker5, install .net6 environment
Docker pull mcr.microsoft.com/dotnet/aspnet:6.0
6. Build an image
Cd project directory for example: cd web/onezhanmvc (cd to the directory where dockerfile is located, and the build command creates an image based on dockerfile)
Docker build-t image name. For example: docker build-t onezhanmvc. (. Don't forget)
7. Create and run containers
Docker run-d-- name my-dotnet6-demo01-p 8001VR 80-- restart=always onezhanmvc (the name of the image created in the previous step)
Parameter description:
-d # running in the background
-p 8001VR 80 # host port number: docker port number
-- restart=always # dokcer also starts the container automatically when it is restarted
Normally, we can access the IP+ port number of linux externally.
8. Common container commands
View all containers: docker ps-a
Startup container: docker start container name
Restart container: docker restart container name
Stop container: docker stop container name
Delete container: docker rm container name
Delete image: docker rmi image name
These are all the contents of the article "how to deploy Asp.Net6 Core in docker under Linux CentOS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!