具有 Docker 容器优势的 MVC Net Core [英] MVC Net Core with Docker Containers Benefits
问题描述
我正在创建一个带有 C# 后端和 ASP CSS/html/Razor 前端的简单 MVC Net Core 应用程序.这是一个简单的启动项目,客户可以在其中创建订单、购买书籍并放入购物车.Docker 镜像如何支持这一点?或者这对 MVC 来说是否太过分了.
I am creating a simple MVC Net Core app with C# backend, and ASP CSS/html/Razor front end. It is a simple start project where customers can create orders, buy books, and place into a shopping cart. How would Docker images support this? Or would this be an overkill for MVC.
推荐答案
这并不过分.其实很简单,dockerization 带来了很多好处.例如,阅读 Docker 文档上的 .Net Core dockerization 页面:https://docs.docker.com/engine/examples/dotnetcore/
It's not overkill. It's actually quite simple and the dockerization brings a lot of advantages. Read for example the .Net Core dockerization page on Docker docs: https://docs.docker.com/engine/examples/dotnetcore/
一些优点是:
- 可移植性:您可以将已知的工作映像放入另一个环境(开发/测试/暂存/生产)
- 与主机系统隔离
- 可扩展性:将应用容器带到云提供商并根据负载运行实例
您必须考虑持久性:您不应该将数据存储在 docker 容器中,因为在删除容器时这很容易丢失.通常,您会在应用容器旁边启动一个数据库容器,并将其数据存储在卷或主机文件系统中.
You have to think about persistance: You shouldn't store data in the docker container because this can easily be lost when removing the container. Usually you start a database container next to your app container and store it's data in a volume or on the host filesystem.
这篇关于具有 Docker 容器优势的 MVC Net Core的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!