Docker basics 2-basic mirroring operations

Docker basics 2-basic operations such as mirrors and containers:
1. Query basic methods of mirroring [Advanced methods, see cocker basics 1]

docker search centos


[root@centos77 ~]# 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]


The "OFFICIAL" in it represents the officially released version. "STARS" stars-personal understanding is the popular version, we download it by referring to these two parameters.

2. Query which images are downloaded in the system

docker images

3. The way to delete the mirror

docker rmi 镜像id

4. Export image
Example: Take "busybox" as an example for testing


[root@centos77 ~]# docker save -o busy1.tar busybox:latest
[root@centos77 ~]#

[root@centos77 ~]# ls
1.txt    busy1.tar    install.sh  psutil-5.2.2.tar.gz



Or you can export like this


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


5. Import the image
5.1 First delete the container that uses the image


[root@centos77 ~]# 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 
[root@centos77 ~]# docker rm 1811
1811

5.2 Deleting the mirror


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

删除镜像busybox的id“b97242f89c8a”可以简写
[root@centos77 ~]# docker rmi b97
Untagged: busybox:latest
Untagged: busybox@sha256:c5439d7db88ab5423999530349d327b04279ad3161d7596d2126dfb5b02bfd1f
Deleted: sha256:b97242f89c8a29d13aea12843a08441a4bbfc33528f55b60366c1d8f6923d0d4
Deleted: sha256:0064d0478d0060343cb2888ff3e91e718f0bffe9994162e8a4b310adb2a5ff74
[root@centos77 ~]#

5.3 Export image
Enter the directory where the image is located, and then execute the import command


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


在查询下就是可以看到镜像已经导入进去了
[root@centos77 ~]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
busybox               latest              b97242f89c8a        8 days ago          1.23MB

Guess you like

Origin blog.csdn.net/wtt234/article/details/112980322