Docker中Ubuntu镜像添加openssh-server服务
2015-01-21 09:45
399 查看
1,首先,需要从docker官网获得centos或Ubuntu镜像
2,当本地已有Ubuntu镜像后(大概200M左右大小),使用如下命令
3,更新源, apt-get update
接着就可以使用 apt-get install openssh-client openssh-server 来安装openssh服务了
需要把此镜像保存一下:
最后,加载刚刚保存到的最新的image,放入到新的容器中去:
4,启动openssh服务
5,此时可以从其他机器登陆到这个docker容器里了
6,可能出现一些错误使得一登陆进去就直接关闭连接了:
此时解决方案:
重启服务:
2,当本地已有Ubuntu镜像后(大概200M左右大小),使用如下命令
docker run -t -i ubuntu /bin/bash即可启动一个容器,并放入Ubuntu镜像
3,更新源, apt-get update
接着就可以使用 apt-get install openssh-client openssh-server 来安装openssh服务了
需要把此镜像保存一下:
docker commit [container-id] [image-id]在把刚刚的container干掉:
docker stop [container-id]嗯,还需要将这个container删除掉
docker rm [container-id]
最后,加载刚刚保存到的最新的image,放入到新的容器中去:
docker run --name [image-name] -i -t -p 50001:22 [image-id]
4,启动openssh服务
/etc/init.d/ssh start
5,此时可以从其他机器登陆到这个docker容器里了
6,可能出现一些错误使得一登陆进去就直接关闭连接了:
[root@Wshare84 start_docker_sh]# ssh root@10.10.2.84 -p 50001 The authenticity of host '[10.10.2.84]:50001 ([10.10.2.84]:50001)' can't be established. RSA key fingerprint is aa:05:84:4c:f2:15:f3:04:89:9c:04:33:0d:15:14:1f. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '[10.10.2.84]:50001' (RSA) to the list of known hosts. root@10.10.2.84's password: Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 2.6.32-431.el6.x86_64 x86_64) * Documentation: https://help.ubuntu.com/ Last login: Wed Jan 21 01:25:17 2015 from 172.17.42.1 Connection to 10.10.2.84 closed.
此时解决方案:
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
echo 'root:yourpasswd' | chpasswd //设置root密码
vi /etc/ssh/sshd_config将PermitRootLogin 改为 yes,将 UsePAM 改为 no。
重启服务:
/etc/init.d/ssh restart
相关文章推荐
- Docker实战-为镜像添加SSH服务
- 解决live CD方式启动Ubuntu系统不能启动openssh-server服务
- Docker实战(七)之为镜像添加SSH服务
- Ubuntu server下面的openssh server服务安装试玩
- ubuntu server 添加SVN服务给service管理
- 解决live CD方式启动Ubuntu系统不能启动openssh-server服务
- Docker应用--创建带有sshd服务的Ubuntu镜像
- ubuntu server telnet 服务(转)
- ssh服务-再次冲击Ubuntu之server篇
- ubuntu server 10.4 下LVS-DR+heartbeat +Ldirectord实现web服务高可性负载均衡实验
- ubuntu server 10.10安装ssh服务
- ubuntu server10.4下NIS服务的配置
- 如何在ubuntu server 10.04 安装jboss4.2.3GA服务?
- 解决Ubuntu下eclipse无法添加server的问题
- Ubuntu Server系列各项服务的安装和维护 MySQL的安装
- Ubuntu Server系列各项服务的安装和维护 PHP的配置
- 为Ubuntu Server 添加硬盘
- ubuntu server 9.04下配置ftp服务和可读写samba服务
- SQL_SERVER2005镜像服务配置
- ubuntu server 如何下载openssh-server