[英]How can a .net core web app docker image run on Mac OS?
Ok I know I'm being a noob here but I'm trying to get my head around Docker... I've created a simple .net core Web API app that returns some data.好的,我知道我在这里是个菜鸟,但我正在尝试了解 Docker...我已经创建了一个简单的 .net 核心 Web API 应用程序,它返回一些数据。 I did this in Windows, pushed to gitlab, but then I can clone on Mac and runs fine as expected...
我在 Windows 中做了这个,推送到 gitlab,但后来我可以在 Mac 上克隆并按预期运行良好......
I then create a Dockerfile that includes..然后我创建一个 Dockerfile,其中包括..
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
...
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
As I understand it, does the core sdk include the small nano server windows OS?据我了解,核心 sdk 是否包括小型纳米服务器 Windows 操作系统? Does that mean that when I use
docker run
on Mac it's actually running the app on Windows - kind of like in a mini VM on the Mac?这是否意味着当我在 Mac 上使用
docker run
,它实际上是在 Windows 上运行应用程序 - 有点像在 Mac 上的迷你 VM 中?
If this is correct, how does docker know to use the windows nano server, rather than a linux image for example?如果这是正确的,docker 如何知道使用 windows nano 服务器,而不是例如 linux 映像?
Thanks for any help谢谢你的帮助
Because .NET Core is cross-platform.因为 .NET Core 是跨平台的。 And docker works on Mac and Windows (theoretically just the way it works on Linux) the image will work just fine on any platform.
并且 docker 在 Mac 和 Windows 上工作(理论上只是在 Linux 上的工作方式),该图像在任何平台上都可以正常工作。
mcr.microsoft.com/dotnet/core/sdk:3.1 is platform dependent. mcr.microsoft.com/dotnet/core/sdk:3.1 取决于平台。 Depending on the architecture you choose to run Docker it'll pick up Windows Nano server or Linux template.
根据您选择运行 Docker 的架构,它会选择 Windows Nano 服务器或 Linux 模板。
Docker is not a VM technology. Docker 不是虚拟机技术。 It's a Linux feature that provides you an isolated environment.
它是一个 Linux 功能,可为您提供隔离环境。 Docker is not possible on Windows and Mac.
Docker 在 Windows 和 Mac 上是不可能的。 Docker uses Linux features and plugs in an application (and it's related dependencies) in the Linux environment and creates an illusion of resources (network, RAM, disk, software frameworks) needed for running the application.
Docker 使用 Linux 功能并在 Linux 环境中插入应用程序(及其相关依赖项),并创建运行应用程序所需的资源(网络、RAM、磁盘、软件框架)的错觉。
On windows and Mac.在 Windows 和 Mac 上。 Docker installs a Linux VM.
Docker 安装 Linux VM。 And runs the Docker infra inside the VM.
并在 VM 内运行 Docker 基础设施。
commands like docker info
will give more details.诸如
docker info
类的命令将提供更多详细信息。 This picture below shows that it's running on Linux.下图显示它在 Linux 上运行。
Switching to Windows docker will give a different output for docker info
command.切换到 Windows docker 将为
docker info
命令提供不同的输出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.