Windows 2016 TP5上的Docker初次体验

本文讲的是Windows 2016 TP5上的Docker初次体验 【编者的话】微软5.28发布Windows 2016 Technical Preview 5,作者第一时间上手,记录发现的新变化,看样子要接着往下写呢。这是第一篇,快来瞅瞅吧。

昨天(2016年4月28日),微软宣布Windows 2016 Technical Preview 5可用。我当然要赶紧查看一下新的TP5和去年11月份发布的TP4有什么不同了。

因为还没找到Azure模板(更新:今天我找到了 Windows Server 2016 Technical Preview 5 ),我是在 TP5 branch 上准备封装模板(packer templates)的,不过想要自动构建和安装Docker以及Docker基本镜像,还需要一些修改。
01.png

虽然没有一个完美的解决方案,但构建第一个Vagrant box也是一个很好的开头,剩下的步骤就手动按照这篇来 Container Host Deployment - Windows Server

我真是要陷到这个自动化工作流里面去了
  1. packer build
  2. vagrant box add
  3. vagrant up
  4. vagrant destroy -f

不过你不会,因为要建立一个这样的测试环境,设置起来很难。

如果你没这个耐心去搞一个完整的封装模板,可以按照 Arun Gupta的步骤在VirtualBox创建一个TP5 VM

下面我们来看看TP5有什么新东西吧。

太快了—再也不用sleep

在TP5中用Windows Dockerfile创建Docker镜像,比之前在TP4中 多了,另外以前每个 run 命令中都要sleep几秒,现在sleep完全没必要,赶紧删了吧。 

IP地址可查

之前TP4中的一个移植障碍( Docker Birthday app to TP4 Windows containers )是不能获取每个容器的IP地址。现在只要运行 docker inspect 便可以显示容器IP了。
02.png

之后我会测试 docker-compose.yml 文件中的链接,看是否能用简单的host名建立一个简单的多容器应用。

不过这已经是Windows容器网络的一次提升了。

npipe就是你的unix socket

还有一个有意思的事儿,Docker引擎现在可以监听一个Windows命名的管道(pipe),就像Linux上的Unix socket。

这就导致你运行Docker命令的行为非常Unix化,你必须要“sudo”一下:
在没有管理员权限时尝试运行Docker客户端,你根本就连不上。
03.png

有一个办法可以允许指定用户使用这个命名管道,类似在Linux上把用户添加到docker group,不过我在这次小测试中还没找到这个group的名字。

Kitematic 和 Windows兼容(Kitematic meets Windows (again))

当晚我还在并行虚拟机中玩了一把Windows测试版的Docker,虚拟机中同时安装了Kitematic。因为测试版不是通过VirtualBox使用Kitematic的,我认为在TP5上应该也能用。所以我移除了Beta download的压缩文件,稍微调整了我的TP5设置,使得Kitematic和Window Docker Engine之间可以通信。

我采取的方法相当实用,把本地TCP端口2375添加到Docker Engine:
notepad C:\ProgramData\docker\runDockerDaemon.cmd  

再把dockerd命令改成:
dockerd -H npipe:// -H 127.0.0.1:2375

然后运行:
restart-service docker  

下载的测试版kitematic也会搜索 docker.local ,所以我在主机表中加了回环IP地址:
notepad C:\Windows\system32\drivers\etc\hosts  

04.png

现在Kitematic启动时不再创建新的本地的虚拟机,也不会在左侧的窗口显示本地Windows容器了。启动时不再创建新的本地的虚拟机,也不会在左侧的窗口显示本地Windows容器了。

TP5还有很多东西要去探索,现在你能可以在Docker Hub上pull/push Docker镜像。

敬请期待即将出炉的新博客。有了TP5,社区可以更好的关注Docker在Windows上的进步,还能查看Windows Docker Engine上的最新改进和pull请求。

如果这篇文章对你有用,请分享给朋友和同事。如果你有问题或更好的建议,请留下评论。你还可以在推特 @ stefscherer 关注我。

原文链接:First impressions of Docker on Windows 2016 TP5(翻译:马远征)

原文发布时间为:2016-04-30
本文作者:夕口夕 
本文来自云栖社区合作伙伴DockerOne,了解相关信息可以关注DockerOne。
原文标题:Windows 2016 TP5上的Docker初次体验
Docker on Windows by Elton Stoneman English | 14 July 2017 | ISBN: 1785281658 | 358 Pages | AZW3/EPUB/MOBI/PDF (conv) | 23.77 MB Key Features Start building applications as Docker images and running containers in a Windows production environment Design and implement distributed applications that run across multiple networked containers Build a full Continuous Deployment pipeline for a .NET Core application running on Windows Book Description Docker has become hugely popular because it offers benefits at all stages of software design and delivery. Until recently, it was impossible to use a Windows Server platform to host the Docker Engine without adding an additional layer of virtualization. Starting with Windows Server 2016, you are able to use Docker on Windows and take advantage to easily build, deploy, and run Windows Containers. From building and running simple images to designing and implementing distributed applications, this book will teach everything you need to know while using Docker on Windows. You will start by installing Docker on different versions of Windows and Windows Server, and run a simple container to verify that the setup is working correctly. You will see how to build Docker images with a Dockerfile for a simple website, and then run it on Windows. Moving on, we'll cover the practical usage of Docker and the tools in the Docker ecosystem, such as Docker Compose, Docker Trusted Registry, and Docker Swarm Mode. Then, you'll be able to apply that knowledge by building a full continuous deployment pipeline for a .NET Core application running on Windows. We'll also dive deep into some of the core features of Docker, such as networking and security. At the end of the book, you'll be guided through a business case that will help you practically implement Docker in a real-world scenario. What you will learn Understand how Docker works, build images, and run containers Run Docker on different versions of Windows, and on the cloud with Azure Des
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值