在docker容器中安装和使用,linux版的powershell 1 在任意版本的linux中,安装docker,并启动服务。详见手册: 2 微软powershell on linux on docker官网 3 从官网查看有哪些docker镜像: 4 下载并运行docker版的powershell: 5 是否需要【虚拟机和linux层】之辩。

powershell 传教士 原创文章。始于 2016-09-18 ,2016-10-27修改powershell 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。

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

---完---