1、列舉本地所有容器
$ sudo docker ps -a
container id image command created status ports names
6b643e4e7c2d ror-centos-20180524001 "/bin/bash" 16 minutes ago exited (0) 45 seconds ago sleepy_mcclintock
f44cf0ebec18 centos "/bin/bash" 40 minutes ago exited (0) 24 minutes ago nostalgic_darwin
30b57f142412 centos "/bin/bash" about an hour ago exited (127) about an hour ago xenodochial_booth
379adebe4b02 centos "/bin/bash" about an hour ago exited (127) about an hour ago sharp_easley
如果不帶-a則只列舉正在執行的容器
2、啟動指定容器
$ sudo docker start 6b643e4e7c2d
6b643e4e7c2d
3、停止指定容器
$ sudo docker stop 6b643e4e7c2d
6b643e4e7c2d
4、介入乙個已經執行的容器
$ sudo docker attach 6b643e4e7c2d
[root@6b643e4e7c2d /]#
或者$ sudo docker exec -it 6b643e4e7c2d /bin/sh
sh-4.2#
這兩個命令的區別在於,attach命令介入容器後,執行exit會退出docker程序,從而導致docker停止。
而exec介入的話,執行exit退出只是退出容器的sh,不會導致docker停止。
5、刪除容器
$ sudo docker rm 6b643e4e7c2d
6b643e4e7c2d
$ sudo docker ps -a
container id image command created status ports names
f44cf0ebec18 centos "/bin/bash" about an hour ago exited (0) about an hour ago nostalgic_darwin
30b57f142412 centos "/bin/bash" about an hour ago exited (127) about an hour ago xenodochial_booth
379adebe4b02 centos "/bin/bash" 2 hours ago exited (127) about an hour ago sharp_easley
Docker映象操作
列出映象 docker images 檢視映象的詳細資訊 docker inspect 映象名 容器名 刪除映象 docker rmi 映象名 docker rmi imageid docker rmi docker images q ubuntu 刪除所有的ubuntu倉庫映象 查詢映象 dock...
Docker 映象操作
如果你需要從網路中查詢需要的映象,可以通過以下命令搜尋 docker search 映象名稱 如需要python docker search python 也可以到搜尋需要的映象 docker pull 映象名稱 版本 docker pull centos centos7.7.1908docker ...
Docker 映象操作
如果你需要從網路中查詢需要的映象,可以通過以下命令搜尋 docker search 映象名稱 如需要python docker search python 也可以到搜尋需要的映象 docker pull 映象名稱 版本 docker pull centos centos7.7.1908docker ...