windows docker 安装centos,并通过ssh连接

###前言
之前在window下都是使用vmware安装linux虚拟机,需要进行繁琐的网络配置。最近换了一台新电脑,想装个centos玩玩,,于是选择docker安装centos,简单轻量。
###详细过程
前提:win10、已安装docker
1、从dockers hub上查看我们需要的centos版本,这里我安装centos6.7
(尝试过centos7,但是用起来报一些奇怪的错,据说与docker存在一些兼容问题)
windows docker 安装centos,并通过ssh连接

windows docker 安装centos,并通过ssh连接

2、拉取镜像
docker pull centos:6.7 格式为 镜像名:TAG
windows docker 安装centos,并通过ssh连接
3、拉取完之后,查看一下镜像
windows docker 安装centos,并通过ssh连接
4、以互交方式后台运行容器
docker run -it -d -p 50001:22 192ad0341c8b /bin/bash
windows docker 安装centos,并通过ssh连接
5、查看当前运行的容器,并进入容器
docker ps
windows docker 安装centos,并通过ssh连接
docker attach 196b2ee2dec4
windows docker 安装centos,并通过ssh连接
6、查看网络配置
windows docker 安装centos,并通过ssh连接
7、安装ssh服务
yum install openssh-server -y
windows docker 安装centos,并通过ssh连接
启动ssh
service sshd start

8、修改sshd_config配置
vi /etc/ssh/sshd_config
windows docker 安装centos,并通过ssh连接
windows docker 安装centos,并通过ssh连接
windows docker 安装centos,并通过ssh连接
windows docker 安装centos,并通过ssh连接

windows docker 安装centos,并通过ssh连接

配置完成,可以通过ssh连接docker上的centos了。