[root@localhost docker_test]# docker run bigni/test3 #运行docker so easy ![root@localhost docker_test]# docker container ls #查看在运行的tontainer,发现没有上面运行的container,原因是上面的程序不是常驻内存的进程,程序结束后,docker便退出了。CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES[root@localhost docker_test]# docker container ls -a #查看所有container,包括退出的CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES8c3e652d7321 bigni/test3 "/soeasy.sh" 14 seconds ago Exited (0) 13 seconds ago xenodochial_diffie80e6e373f1d4 cfbfd0a29d1c "/soeasy.sh" 36 minutes ago Exited (0) 36 minutes ago dreamy_mendel934e574a077d e2b5b08cc31c "/soeasy.sh" 39 minutes ago Exited (1) 39 minutes ago nostalgic_lehmann871a7d62acc1 f5620b92331c "/soeasy2" About an hour ago Exited (15) About an hour ago serene_spence72fd56c76100 hello-world "/hello" 43 hours ago Exited (0) 43 hours ago trusting_pasteur[root@localhost docker_test]# [root@1c4586fe95ee /]# touch test.sh #container是在image之上创建的一个可读写的layer [root@1c4586fe95ee /]# ls anaconda-post.log bin dev etc home lib lib64 media mnt opt proc root run sbin srv sys test.sh tmp usr var [root@1c4586fe95ee /]#
想办法让常驻内存,比如可以进入 centos 交互式运行
[root@localhost docker_test]# docker run -it centos[root@1c4586fe95ee /]# lsanaconda-post.log bin dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var[root@1c4586fe95ee /]# ifconfig #这个centos发行版很多工具没装bash: ifconfig: command not found[root@1c4586fe95ee /]# vimbash: vim: command not found[root@1c4586fe95ee /]# vi[root@1c4586fe95ee /]#
进入到centos操作系统了,这时我在宿主机另起一个session查看containers
[root@localhost docker_test]# docker container lsCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES1c4586fe95ee centos "/bin/bash" About a minute ago Up About a minute agitated_banzai[root@localhost docker_test]#