zoukankan      html  css  js  c++  java
  • Docker(二) 镜像

    简介

    Docker镜像是什么?
    它是一个只读的文件,就类似于我们安装操作系统时候所需要的那个iso光盘镜像,通过运行这个镜像来完成各种应用的部署。

    这里的镜像就是一个能被docker运行起来的一个程序。

    查看镜像资源操作命令

    docker image 
    
    Usage:	docker image COMMAND
    
    Manage images
    
    Options:
          --help   Print usage
    
    Commands:
      build       Build an image from a Dockerfile
      history     Show the history of an image
      import      Import the contents from a tarball to create a filesystem image
      inspect     Display detailed information on one or more images
      load        Load an image from a tar archive or STDIN
      ls          List images
      prune       Remove unused images
      pull        Pull an image or a repository from a registry
      push        Push an image or a repository to a registry
      rm          Remove one or more images
      save        Save one or more images to a tar archive (streamed to STDOUT by default)
      tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
    
    Run 'docker image COMMAND --help' for more information on a command.
    

    搜索镜像资源

    命令格式:docker search [image_name]
    
    [root@VM_0_4_centos docker]# docker search nginx
    INDEX       NAME                                        DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
    docker.io   docker.io/nginx                             Official build of Nginx.                        12386     [OK]       
    docker.io   docker.io/jwilder/nginx-proxy               Automated Nginx reverse proxy for docker c...   1704                 [OK]
    docker.io   docker.io/richarvey/nginx-php-fpm           Container running Nginx + PHP-FPM capable ...   749                  [OK]
    docker.io   docker.io/linuxserver/nginx                 An Nginx container, brought to you by Linu...   84                   
    docker.io   docker.io/bitnami/nginx                     Bitnami nginx Docker Image                      73                   [OK]
    docker.io   docker.io/tiangolo/nginx-rtmp               Docker image with Nginx using the nginx-rt...   60                   [
    

    OFFICIAL [OK] 说明是官方提供的镜像

    获取镜像

    命令格式:docker pull [image_name]
    

    拉取mysql镜像

    [root@VM_0_4_centos docker]# docker pull docker.io/mysql
    Using default tag: latest
    Trying to pull repository docker.io/library/mysql ... 
    latest: Pulling from docker.io/library/mysql
    d599a449871e: Pull complete 
    f287049d3170: Pull complete 
    08947732a1b0: Pull complete 
    96f3056887f2: Pull complete 
    871f7f65f017: Pull complete 
    1dd50c4b99cb: Pull complete 
    5bcbdf508448: Pull complete 
    a59dcbc3daa2: Pull complete 
    13e6809ab808: Pull complete 
    2148d51b084d: Pull complete 
    93982f7293d7: Pull complete 
    e736330a6d9c: Pull complete 
    Digest: sha256:c93ba1bafd65888947f5cd8bd45deb7b996885ec2a16c574c530c389335e9169
    Status: Downloaded newer image for docker.io/mysql:latest
    

    查看本地镜像

    命令格式:docker image ls 
    命令格式:docker image
    

    删除镜像资源

    命令格式:docker image rm [image_id/image_name:image_version]  
    命令格式:docker rmi [image_id/image_name:image_version] 
    

    镜像重命名

    docker tag [old_image]:[old_version] [new_image]:[new_version]
    
    [root@VM_0_4_centos docker]# docker image ls
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    docker.io/mysql     latest              d435eee2caa5        4 weeks ago         456 MB
    [root@VM_0_4_centos docker]# docker tag docker.io/mysql:latest my_mysql:1.0
    [root@VM_0_4_centos docker]# docker image ls
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    docker.io/mysql     latest              d435eee2caa5        4 weeks ago         456 MB
    my_mysql            1.0                 d435eee2caa5        4 weeks ago         456 MB
    

    导出镜像

    将已经下载好的镜像,导出到本地,以备后用

    命令格式:docker save -o [包文件] [镜像]
    命令格式:docker save [镜像1] ... [镜像n] > [包文件]
    
    docker save  docker.io/mysql > mysql.tar
    

    导入镜像

    命令格式:docker load < [image.tar_name]
    命令格式:docker load --input [image.tar_name]
    
    docker load < mysql.tar
    
  • 相关阅读:
    卷积神经网络
    TensorFlow线性回归
    TensorFlow常用操作
    TensorFlow基本计算单元——变量
    Pandas基础
    Numpy基础
    Python基础
    Windows下安装TensorFlow教程
    mongodb并列查询,模糊查询
    C#对Mongodb数组对象操作
  • 原文地址:https://www.cnblogs.com/snailrunning/p/12112122.html
Copyright © 2011-2022 走看看