docker鏡像管理命令學習

查看當前鏡像

[root@ztydl ~]# docker images
REPOSITORY                              TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos-wget                             latest              9e694366ecc0        29 minutes ago      312.9 MB
centos                                  latest              1c1b67b33c28        3 weeks ago         196.6 MB
daocloud.io/centos                      7                   1c1b67b33c28        3 weeks ago         196.6 MB
zty                                     latest              32e90b4dd628        3 weeks ago         108.3 MB
daocloud.io/daocloud/daocloud-toolset   latest              2a2ecdfa41dc        6 months ago        147.1 MB

根據鏡像ID刪除鏡像(-f force 強行刪除)

[root@ztydl ~]# docker rmi 32e90b4dd628
Error response from daemon: Conflict, cannot delete image 32e90b4dd628 because it is tagged in multiple repositories, use -f to force
Error: failed to remove images: [32e90b4dd628]

搜索docker鏡像

[root@ztydl ~]# docker search nginx

根據鏡像名下載 鏡像

[root@ztydl ~]# docker pull nginx

根據鏡像ID給鏡像打標籤

[root@ztydl ~]# docker tag 1c1 centos

運行docker鏡像

[root@ztydl ~]# docker run -it centos /bin/bash
[root@ac14ee1c187c /]# ls
anaconda-post.log  dev  home  lib64       media  opt   root  sbin  sys  usr
bin                etc  lib   lost+found  mnt    proc  run   srv   tmp  var

查看正在運行的容器

[root@ztydl ~]# docker ps

查看左右容器

[root@ztydl ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
ac14ee1c187c        centos              "/bin/bash"         18 seconds ago      Exited (0) 8 seconds ago                       berserk_curie       

使用指定鏡像 運行容器

[root@ztydl ~]# docker  run -it --name vm1 centos bash
-d: 後臺運行容器,並返回容器ID-i: 以交互模式運行容器,通常與 -t 同時使用;
-t: 爲容器重新分配一個僞輸入終端,通常與 -i 同時使用;
--name="nginx-lb": 爲容器指定一個名稱;

將正在運行的已做修改的 容器 生成新的鏡像

[root@ztydl ~]# docker commit -m "test asd" -a "ztyzty" 311ad zty-centos
50be09cb7fbc575053e73772f9af7fdbf89c65d993120462d8c56b73b0c3d7f4

[root@ztydl ~]# docker images
REPOSITORY                              TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
zty-centos                              latest              50be09cb7fbc        15 seconds ago      198.3 MB

將已有鏡像保存爲本地文件

[root@ztydl ~]# docker save -o zty-centos.tar.gz zty-centos

[root@ztydl ~]# docker load < zty-centos.tar.gz

使用本地模板 導入鏡像

[root@ztydl ~]# cat zty-centos.tar.gz |docker import - import_os
d83c7b9794a3e1ae88ff8093c4103fbbec34941f917ea1e890bf5b8c84e31729
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章