1. 程式人生 > 其它 >docker基礎2--映象基本操作

docker基礎2--映象基本操作

技術標籤:虛擬機器相應內容

docker基礎2–映象、容器等基本操作:
1.查詢映象基礎方法[高階方法,見cocker基礎1]

docker search centos


[[email protected] ~]# docker search centos
NAME                               DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
centos                             The official build of CentOS.                   6370                [
OK] ansible/centos7-ansible Ansible on Centos7 132 [OK] consol/centos-xfce-vnc Centos container with "headless" VNC session… 125 [OK] jdeathe/centos-ssh OpenSSH / Supervisor / EPEL/IUS/SCL Repos - … 117 [
OK] centos/systemd systemd enabled base container. 93 [OK] centos/mysql-57-centos7 MySQL 5.7 SQL database server 87 imagine10255/centos6-lnmp-php56 centos6-lnmp-php56 58 [
OK] tutum/centos Simple CentOS docker image with SSH access 46 centos/postgresql-96-centos7 PostgreSQL is an advanced Object-Relational … 45 kinogmt/centos-ssh CentOS with SSH 29 [OK] pivotaldata/centos-gpdb-dev CentOS image for GPDB development. Tag names… 13 guyton/centos6 From official centos6 container with full up… 10 [OK]

這裡面的“OFFICIAL”是代表 官方釋出的版本。“STARS”星星–個人理解就是熱門版本,我們下載就是參照這兩個引數就是可以了

2.查詢系統中下載了哪些映象

docker images

3.刪除映象的辦法

docker rmi 映象id

4.匯出映象
示例:以“busybox”為例進行測試


[[email protected] ~]# docker save -o busy1.tar busybox:latest
[[email protected] ~]#

[[email protected] ~]# ls
1.txt    busy1.tar    install.sh  psutil-5.2.2.tar.gz



或者這樣匯出也可以


[[email protected] ~]# docker save > busy2.tar busybox:latest
[[email protected] ~]# ls
1.txt  anaconda-ks.cfg  busy1.tar  busy2.tar  
[[email protected] ~]#


5.匯入映象
5.1先刪除使用映象的容器


[[email protected] ~]# docker ps -a
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS                    PORTS                    NAMES
1811ea42d922        busybox:latest        "/bin/sh"                2 days ago          Exited (137) 2 days ago                            vibrant_vaughan
156f134c5468        nginx                 "nginx -g 'daemon 
[[email protected] ~]# docker rm 1811
1811

5.2在刪除映象


[[email protected] ~]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
busybox               latest              b97242f89c8a        8 days ago          1.23MB

刪除映象busybox的id“b97242f89c8a”可以簡寫
[[email protected] ~]# docker rmi b97
Untagged: busybox:latest
Untagged: [email protected]:c5439d7db88ab5423999530349d327b04279ad3161d7596d2126dfb5b02bfd1f
Deleted: sha256:b97242f89c8a29d13aea12843a08441a4bbfc33528f55b60366c1d8f6923d0d4
Deleted: sha256:0064d0478d0060343cb2888ff3e91e718f0bffe9994162e8a4b310adb2a5ff74
[[email protected] ~]#

5.3匯出映象
進入映象所在的目錄,然後執行匯入命令


[[email protected] ~]# ls
1.txt  anaconda-ks.cfg  busy1.tar  busy2.tar  initial-setup-ks.cfg  install.sh  psutil-5.2.2.tar.gz
[[email protected] ~]# docker load -i busy1.tar
0064d0478d00: Loading layer [==================================================>]   1.45MB/1.45MB
Loaded image: busybox:latest
[[email protected] ~]#


在查詢下就是可以看到映象已經匯入進去了
[[email protected] ~]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
busybox               latest              b97242f89c8a        8 days ago          1.23MB