PowerShell免费软件

在docker容器中安装和使用,linux版的powershell

powershell 传教士 原创文章。始于 2016-09-18 ,2016-10-27修改powershell docker官网。允许转载,但必须保留名字和出处,否则追究法律责任

 

 

1 在任意版本的linux中,安装docker,并启动服务。详见手册:

https://docs.docker.com/engine/installation/linux

 1.1 centos 6 安装docker:
yum install epel-release
rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel  install  kernel-lt -y
yum install  docker-io -y
调整 /boot/grub/grub.conf 让 3.10内核成为默认,或者在启动时选择。
重启机子并选择3。10内核。并确保docker服务起来了。

2 微软powershell on linux on docker官网

https://hub.docker.com/r/microsoft/powershell/

上面的网址是【powershell-docker开源官网】,每个最新版本发布2---3天后,这里就会更新。 其他的都是第三方的,docker中的powershell版本较旧,不建议使用。

 

 

3 从官网查看有哪些docker镜像:

https://hub.docker.com/r/microsoft/powershell/tags/

 

4 下载并运行docker版的powershell:

docker run -it -v /宿主机目录必须为绝对路径:冒号后为镜像内挂载的路径    镜像名字

 

例子:
#------------------------------------------------------------------
mkdir /powershell
docker run -it -v /powershell:/mnt      microsoft/powershell   #运行默认的powershell
#------------------------------------------------------------------
mkdir /powershell
docker run -it -v /powershell:/mnt      microsoft/powershell:ubuntu14.04   #运行ubuntu1404的powershell
#------------------------------------------------------------------
mkdir /powershell
docker run -it -v /powershell:/mnt      microsoft/powershell:ubuntu16.04   #运行ubuntu1604的powershell
#------------------------------------------------------------------
mkdir /powershell
docker run -it -v /powershell:/mnt      microsoft/powershell:centos7   #运行centos7的powershell
#------------------------------------------------------------------
注:本地 docker 镜像保存在 /var/lib/docker 的子目录中。

 

原来我在centos7上使用powershell。但是每当有新版本就要卸载旧的,安装新的,麻烦。

而且,github的存储空间是在美国的亚马逊,下载很慢,还要重试很多次。

而从docker hub下载最新版的完整镜像,国内就很快。而且免安装。而且也就200MB。现在学聪明了,大家都用这个方法吧,呵呵。

 

上述命令在 虚拟机 + fedora24 + docker 中测试通过

 

5 是否需要【虚拟机和linux层】之辩。

对于win中使用docker,我们可以不需要linux,直接用,即:

win + docker容器(如Boot2Docker) + 容器中的powershell。

那么,它和:

win + 虚拟机 + linux + docker容器 + 容器中的powershell。

这样用,对比来讲有什么优缺点?谁谈谈?

 

---完---

 

posted on   PowerShell免费软件  阅读(2952)  评论(1编辑  收藏  举报

编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示