Fork me on GitHub

Docker之宿主机ssh至docker容器

下载docker:

https://www.docker.com/products/overview

下载镜像:

docker pull centos

查看镜像:
docker images

创建镜像对应的容器,并指定IP地址和端口号:

docker run -itd -p 127.0.0.1:50001:22 centos /bin/bash

安装ssh服务:
yum install openssh-server

解决ssh_exchange_identification: Connection closed by remote host:

ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key

解决WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!:

  vim ~/.ssh/known_hosts
  删除其中对应IP的密钥

宿主机ssh连接容器:

posted @ 2017-01-31 22:23  郑斌blog  阅读(5426)  评论(0编辑  收藏  举报