docker--container

 

 

 

 

 

[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               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
[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 交互式運行git

[root@localhost docker_test]# docker run -it centos
[root@1c4586fe95ee /]# ls
anaconda-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 /]# vim
bash: vim: command not found
[root@1c4586fe95ee /]# vi
[root@1c4586fe95ee /]# 

進入到centos操做系統了,這時我在宿主機另起一個session查看containersdocker

[root@localhost 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
[root@localhost docker_test]# 
相關文章
相關標籤/搜索