[root@docker ~]# docker ps -l
[root@docker ~]# docker commit 3a7b6994bb2a winse/hadoop # 保存为自己使用的版本
[root@docker ~]# docker run -d winse/hadoop /usr/sbin/sshd
f5cb57f6ec22dd9d257bf610322e2bd547ea0064262fcad63308b932c0490670
[root@docker ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f5cb57f6ec22 winse/hadoop:latest /usr/sbin/sshd 2 seconds ago Exited (0) 2 seconds ago sharp_rosalind
[root@docker ~]# docker run -d -p 8888:22 winse/hadoop /usr/sbin/sshd -D
f9814253159373e8a8df3261904200a733b41c63f55708db3cb56a7ebf650cef
[root@docker ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f98142531593 winse/hadoop:latest /usr/sbin/sshd -D 5 seconds ago Up 4 seconds 0.0.0.0:8888->22/tcp boring_bell
[root@docker ~]# ssh localhost -p 8888
The authenticity of host '[localhost]:8888 ([::1]:8888)' can't be established.
RSA key fingerprint is f5:5e:be:ae:ea:b1:ed:e8:49:43:28:9e:80:87:0d:86.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[localhost]:8888' (RSA) to the list of known hosts.
root@localhost's password:
Last login: Mon Sep 29 14:48:23 2014 from localhost
-bash-4.1#
[root@docker ~]# docker run -t -i winse/hadoop /bin/bash
bash-4.1# ssh localhost
ssh: connect to host localhost port 22: Connection refused
bash-4.1# service sshd start
Starting sshd: [ OK ]
bash-4.1# ifconfig
eth0 Link encap:Ethernet HWaddr 1E:2B:23:16:98:7E
inet addr:172.17.0.31 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::1c2b:23ff:fe16:987e/64 Scope:Link
# 新开一个终端
[root@docker ~]# ssh 172.17.0.31
The authenticity of host '172.17.0.31 (172.17.0.31)' can't be established.
RSA key fingerprint is f5:5e:be:ae:ea:b1:ed:e8:49:43:28:9e:80:87:0d:86.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.17.0.31' (RSA) to the list of known hosts.
root@172.17.0.31's password:
Last login: Mon Sep 29 14:48:23 2014 from localhost
-bash-4.1#