zoukankan      html  css  js  c++  java
  • 05、镜像操作

    1、搜索官方仓库镜像

    [root@hackerlin ~]# docker search nginx
    INDEX       NAME                                         DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
    docker.io   docker.io/nginx                              Official build of Nginx.                        12953     [OK]       
    docker.io   docker.io/jwilder/nginx-proxy                Automated Nginx reverse proxy for docker c...   1769                 [OK]
    docker.io   docker.io/richarvey/nginx-php-fpm            Container running Nginx + PHP-FPM capable ...   764                  [OK]
    docker.io   docker.io/linuxserver/nginx                  An Nginx container, brought to you by Linu...   102                  
    docker.io   docker.io/bitnami/nginx                      Bitnami nginx Docker Image                      82                   [OK]
    docker.io   docker.io/tiangolo/nginx-rtmp                Docker image with Nginx using the nginx-rt...   67                   [OK]

    搜索结果解释:

    name    镜像名称

    DESCRIPTION    镜像说明

    STARS    点赞数量

    OFFICIAL   是否是官方的

    AUTOMATED  是否是自动构建的

    2、镜像拉取

    根据镜像名称(tag指定版本)拉取镜像

    [root@hackerlin ~]# docker pull nginx:1.14-alpine
    Trying to pull repository docker.io/library/nginx ... 
    1.14-alpine: Pulling from docker.io/library/nginx
    bdf0201b3a05: Pull complete 
    3d0a573c81ed: Pull complete 
    8129faeb2eb6: Pull complete 
    3dc99f571daf: Pull complete 
    Digest: sha256:485b610fefec7ff6c463ced9623314a04ed67e3945b9c08d7e53a47f6d108dc7
    Status: Downloaded newer image for docker.io/nginx:1.14-alpine

    注:alpine版本:构建容器小镜像的发型版本

    3、查看当前主机镜像列表

    [root@hackerlin ~]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    docker.io/busybox   latest              83aa35aa1c79        4 weeks ago         1.22 MB
    docker.io/nginx     1.14-alpine         8a2fb25a19f5        12 months ago       16 MB

    4、导出镜像

    [root@hackerlin ~]# docker image save busybox>docker-busybox.tar.gz
    [root@hackerlin ~]# ls docker-busybox.tar.gz 
    docker-busybox.tar.gz
    [root@hackerlin ~]# docker image save -o /usr/local/src/nginx.1.14.tar.gz docker.io/busybox:latest docker.io/nginx:1.14-alpine
    [root@hackerlin ~]# ll /usr/local/src/nginx.1.14.tar.gz 
    -rw-------. 1 root root 18702336 Apr 10 01:59 /usr/local/src/nginx.1.14.tar.gz

    注:

      -o   指定导出镜像的位置

      可以同时导出多个镜像为一个文件

      指定.tar.gz可以导出并压缩

    5、镜像删除

    [root@hackerlin ~]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    docker.io/busybox   latest              83aa35aa1c79        4 weeks ago         1.22 MB
    docker.io/nginx     1.14-alpine         8a2fb25a19f5        12 months ago       16 MB
    [root@hackerlin ~]# docker image rm busybox
    Untagged: busybox:latest
    Untagged: docker.io/busybox@sha256:b26cd013274a657b86e706210ddd5cc1f82f50155791199d29b9e86e935ce135
    Deleted: sha256:83aa35aa1c79e4b6957e018da6e322bfca92bf3b4696a211b42502543c242d6f
    Deleted: sha256:a6d503001157aedc826853f9b67f26d35966221b158bff03849868ae4a821116
    [root@hackerlin ~]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    docker.io/nginx     1.14-alpine         8a2fb25a19f5        12 months ago       16 MB

    6、镜像导入

    [root@hackerlin ~]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    docker.io/nginx     1.14-alpine         8a2fb25a19f5        12 months ago       16 MB
    [root@hackerlin ~]# docker image load -i docker-busybox.tar.gz 
    a6d503001157: Loading layer [==================================================>] 1.437 MB/1.437 MB
    Loaded image: docker.io/busybox:latest
    [root@hackerlin ~]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    docker.io/busybox   latest              83aa35aa1c79        4 weeks ago         1.22 MB
    docker.io/nginx     1.14-alpine         8a2fb25a19f5        12 months ago       16 MB

    7、查看镜像详细信息

    [root@hackerlin ~]# docker inspect docker.io/nginx:1.14-alpine

     

     

  • 相关阅读:
    Docker的ubuntu镜像安装的容器无ifconfig和ping命令的解决
    高德地图api实现地址和经纬度的转换(python)
    数据结构:优先队列 基于堆实现(python版)
    数据结构:优先队列 基于list实现(python版)
    数据结构:堆排序 (python版) 小顶堆实现从大到小排序 | 大顶堆实现从小到大排序
    数据结构:基于list实现二元表达式(python版)
    数据结构:二叉树 基于list实现(python版)
    python之数据库内置方法以及pymysql的使用
    Python之内置函数一
    mysql数据库的安装和基本使用
  • 原文地址:https://www.cnblogs.com/hackerlin/p/12673140.html
Copyright © 2011-2022 走看看