Docker 定制容器镜像的2种方法(2)

[root@docker ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos_sshd 7.0 7bb4efd82c4f 4 minutes ago 310.1 MB docker.io/ubuntu latest e4415b714b62 12 days ago 128.1 MB [root@docker ~]# docker run -d -it --name centos_7.0-1 centos_sshd:7.0 ec17e553d5c4c60865afeb99df8dfd1f4e7d4ba6e1b0d5516f9127f09d1d6356 [root@docker ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ec17e553d5c4 centos_sshd:7.0 "/auto_sshd.sh" 6 seconds ago Up 5 seconds 22/tcp centos_7.0-1

进行ssh测试,先查看一下该容器的ip,之后ssh。ok

[root@docker ~]# docker exec centos_7.0-1 hostname -i 172.17.0.4 [root@docker ~]# ssh root@172.17.0.4 The authenticity of host '172.17.0.4 (172.17.0.4)' can't be established. RSA key fingerprint is 87:88:07:12:ac:0a:90:28:10:e1:9e:eb:1f:d6:c9:9d. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '172.17.0.4' (RSA) to the list of known hosts. root@172.17.0.4's password: Last login: Tue Nov 29 16:00:49 2016 from gateway [root@ec17e553d5c4 ~]# w 16:34:17 up 63 days, 7:49, 1 user, load average: 0.00, 0.02, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 gateway 16:34 1.00s 0.00s 0.00s w [root@ec17e553d5c4 ~]# ping gateway PING gateway (172.17.0.1) 56(84) bytes of data. 64 bytes from gateway (172.17.0.1): icmp_seq=1 ttl=64 time=0.048 ms 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/9604b9f11d4160875db7a60e1ba7d4c3.html