docker--container

Posted laonicc

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker--container相关的知识,希望对你有一定的参考价值。

 

 

 

技术图片

 

 

[[email protected] docker_test]# docker run bigni/test3 #运行
docker so easy !
[[email protected] docker_test]# docker container ls #查看在运行的tontainer,发现没有上面运行的container,原因是上面的程序不是常驻内存的进程,程序结束后,docker便退出了。
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[[email protected] docker_test]# docker container ls -a #查看所有container,包括退出的
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                          PORTS               NAMES
8c3e652d7321        bigni/test3         "/soeasy.sh"        14 seconds ago      Exited (0) 13 seconds ago                           xenodochial_diffie
80e6e373f1d4        cfbfd0a29d1c        "/soeasy.sh"        36 minutes ago      Exited (0) 36 minutes ago                           dreamy_mendel
934e574a077d        e2b5b08cc31c        "/soeasy.sh"        39 minutes ago      Exited (1) 39 minutes ago                           nostalgic_lehmann
871a7d62acc1        f5620b92331c        "/soeasy2"          About an hour ago   Exited (15) About an hour ago                       serene_spence
72fd56c76100        hello-world         "/hello"            43 hours ago        Exited (0) 43 hours ago                             trusting_pasteur
[[email protected] docker_test]# 
[[email protected] /]# touch test.sh #container是在image之上创建的一个可读写的layer
[[email protected] /]# ls
anaconda-post.log  bin  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  test.sh  tmp  usr  var
[[email protected] /]#

想办法让常驻内存,比如可以进入 centos 交互式运行

[[email protected] docker_test]# docker run -it centos
[[email protected] /]# ls
anaconda-post.log  bin  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[[email protected] /]# ifconfig #这个centos发行版很多工具没装
bash: ifconfig: command not found
[[email protected] /]# vim
bash: vim: command not found
[[email protected] /]# vi
[[email protected] /]# 

进入到centos操作系统了,这时我在宿主机另起一个session查看containers

[[email protected] docker_test]# docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS               NAMES
1c4586fe95ee        centos              "/bin/bash"         About a minute ago   Up About a minute                       agitated_banzai
[[email protected] docker_test]# 

 

以上是关于docker--container的主要内容,如果未能解决你的问题,请参考以下文章