Docker for Windows
安装包:点击此处
Get started with Docker for Windows
环境设值:
- Shared Drivers:可以将主机(也就是Windows机器)中的驱动器共享到Docker Container中
- Advanced:用于配置运行Docker Daemon的虚拟环境的CPU和内存
- Network:配置Docker的网络环境
- Proxies:代理的配置
- Docker Daemon:使用JSON格式的设置,对Docker Daemon进行配置,类似于在Linux环境中使用conf文件对Docker进行配置
Docker for Windows的安装过程会在Hyper-V中创建一台用于运行Docker Daemon的Linux虚拟机,这个对话框中的很多配置也就是针对该虚拟机所作出的配置。当配置发生更改后,Docker for Windows会重新启动(小鲸鱼背上的小方块又会动起来),这个过程其实就是这台Linux虚拟机的配置进行动态调整和重启的过程。
服务重启:
在Docker for Windows成功启动后,就可以在Windows命令提示符下执行Docker命令了,也可以在Power Shell中执行Docker命令,看个人喜好吧。Docker CLI的体验和Linux下是一样的。
使用Docker for Windows在容器中运行ASP.NET Core Web API应用程序
1.首先确保Dockerfile文件与发布出来的DockerWebAPI应用程序的文件都在同一个目录下:
2.启动power shell,在程序目录下 执行docker build . -t tagName
与Linux下编译Docker Image相比,这里多了一个安全警告。这是因为我们是在Windows下使用部署在非Windows中的Docker服务来完成的Image的编译生成,两套系统中的文件权限设置不同。Docker for Windows建议在编译生成的Image上对文件的权限进行检查以确保安全。
3.docker run 命令
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
Type exit
to stop the container and close the powershell.
4.浏览器输入url ,测试webapi接口
配置
Shared Drives
Share your local drives (volumes) with Docker for Windows, so that they are available to your containers.
You will be asked to provide your Windows system username and password (domain user) to apply shared drives. You can select an option to have Docker store the credentials so that you don’t have to re-enter them every time.
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· 没有源码,如何修改代码逻辑?
· NetPad:一个.NET开源、跨平台的C#编辑器
· 面试官:你是如何进行SQL调优的?