zoukankan      html  css  js  c++  java
  • Docker深入学习

    一.简单说明

    关于Docker是什么,我们在博文的其它篇幅(https://www.cnblogs.com/yuhaohao/p/10150111.html)已经介绍过,这里就不重复进行介绍,关于Docker的安装,这里我们在centos7的系统直接通过下面的命令安装即可:

    yum install -y docker
    systemctl start docker 
    

    二.Docker的基本操作

    Docker的操作包含:

    • 容器镜像操作
    • 容器及其中应用生命周期操作
    • 容器文件系统操作
    • 容器卷(Volume)操作
    • 容器仓库(Registry)操作
    • 容器网络操作
    • 容器系统操作

    2.1 容器镜像操作

    # 镜像操作:
    build     Build an image from a Dockerfile(这里是构建Docker镜像操作)
    commit    Create a new image from a container's changes(这里是从一个运行的容器里面,修改某些东西保存为一个新的Docker镜像)
    images    List images(列出当前主机Docker镜像)
    load      Load an image from a tar archive or STDIN(导入Docker镜像)
    pull      Pull an image or a repository from a registry(拉取Docker镜像)
    push      Push an image or a repository to a registry(推送Docker镜像)
    rmi       Remove one or more images(删除一个或者多个Docker镜像)
    search    Search the Docker Hub for images(从Dockerhub上查找Docker镜像)
    tag       Tag an image into a repository(将Docker镜像更改TAG)
    save      Save one or more images to a tar archive (streamed to STDOUT by default)(导出一个或者多个Docker镜像为tar包)
    history   显示某镜像的历史
    inspect   获取镜像的详细信息
    

    2.2 容器及其应用生命周期操作

    # 容器及其中应用的生命周期操作:
    create    Create a new container(创建一个容器)        
    kill      Kill one or more running containers(杀掉一个或者多个运行的容器)
    inspect   Return low-level information on a container, image or task(查看运行的容器中的详细信息)
    pause     Pause all processes within one or more containers(暂停一个或者多个容器)
    ps        List containers(列出运行的容器,如果列出所有容器docker ps -a)
    rm        Remove one or more containers(删除一个或者多个容器)
    rename    Rename a container(重命名一个容器)
    restart   Restart a container(重启一个容器)
    run       Run a command in a new container(创建并启动一个容器)
    start     Start one or more stopped containers(启动一个处于停止状态的容器)
    stats     Display a live stream of container(s) resource usage statistics(显示容器实时的资源消耗信息)
    stop      Stop one or more running containers(停止一个处于运行状态的容器)
    top       Display the running processes of a container(列出一个运行的容器中运行的程序)
    unpause   Unpause all processes within one or more containers(继续容器中的所有进程)
    update    Update configuration of one or more containers(更新一个或者多个容器中的配置)
    wait      Block until a container stops, then print its exit code(阻塞运行直到容器停止,然后打印出它的退出代码)
    attach    Attach to a running container(连接到正在运行中的容器)
    exec      Run a command in a running container(在运行的容器中执行命令)
    port      List port mappings or a specific mapping for the container(列出指定的容器的端口映射,或者查找将PRIVATE_PORT NAT到面向公众的端口)
    logs      获取容器的日志
    

    2.3 容器文件系统操作

    cp        Copy files/folders between a container and the local filesystem(用于容器与主机之间的数据拷贝)
    diff      Inspect changes on a container's filesystem(检查容器里文件结构的更改)
    export    Export a container's filesystem as a tar archive(将文件系统作为一个tar归档文件导出到STDOUT)
    import    Import the contents from a tarball to create a filesystem image(从归档文件中创建镜像)
    

    2.4 Docker卷操作

    关于数据卷的类型和相关概念可以参考博文其它篇幅:https://www.cnblogs.com/yuhaohao/p/13877692.html

    # Volume 操作
    volume    Manage Docker volumes
    

    具体操作:

    Usage:  docker volume COMMAND
    
    Manage volumes
    
    Commands:
      create      创建一个数据卷
      inspect     打印一个或多个数据卷的详细信息
      ls          列出所有数据卷
      prune       删除所有未使用的数据卷
      rm          删除一个或多个数据卷
    

    2.5 容器仓库(Registry)操作

    # Docker registry 操作:
    login     Log in to a Docker registry.(登录Docker仓库)
    logout    Log out from a Docker registry.(退出Docker仓库)
    

    2.6 容器网络操作

    docker network命令用于管理网络。可以使用docker network的子命令创建、列出、检查、删除、连接和断开网络。

    # 网络操作
    network   Manage Docker networks
    

    网络子命令如下:

    docker network connect     (将容器连接到网络)
    docker network create      (创建新的Docker网络。默认情况下,在Windows上会采用NAT驱动,在Linux上会采用Bridge驱动。可以使用-d参数指定驱动(网络类型))
    docker network disconnect  (断开容器的网络)
    docker network inspect     (查看Docker网络的详细配置信息)
    docker network ls          (用于列出运行在本地 Docker 主机上的全部网络)
    docker network prune       (删除Docker主机上全部未使用的网络)
    docker network rm          (删除Docker主机上指定网络)
    

    2.7 容器系统操作

    version   Show the Docker version information(查看docker的版本信息)
    events    Get real time events from the server(持续返回docker事件)
    info      Display system-wide information(显示Docker主机系统范围内的信息)
    
  • 相关阅读:
    014_Python3 循环语句
    013_Python3 条件控制
    012_Python3 斐波纳契数列 + end 关键字
    011_Python3 集合
    010_Python3 字典
    009_Python3 元组
    008_Python3 列表
    006_Python3 数字(Number)
    005_Python3 运算符
    bzoj3160
  • 原文地址:https://www.cnblogs.com/yuhaohao/p/13877313.html
Copyright © 2011-2022 走看看