• k8s+docker_part2


    docker+k8s

    目录

    1 简介

    1.1 docker是什么

    • docker是开源项目,诞生于2013年初,由dotCloud公司发布的基于Google公司的Go语言实现
    • 后加入Linux基金会,遵从Apache2.0协议,项目代码在Github维护
    • docker项目的目标是实现轻量级的操作系统虚拟化解决方案
    • docker的基础是Linux容器(LXC)等技术,在LXC上进一步封装,让用户不需要关心容器管理,操作简便

    1.2 为什么要用docker

    1.2.1 docker容器虚拟化的好处

    • 脱离底层物理硬件的限制,更方便的在网络上传播,任何时间任何地点都可获取可使用
    • 新型的创建分布式应用程序,快速分发部署
    • 通过容器来打包应用、解耦应用和运行平台
    • 更加节约时间,且降低部署过程中出现问题的风险

    1.2.2 docker在开发和运维中的优势

    • 更快的交付和部署

      使用docker开发人员可以使用镜像来快速构建一套标准的开发环境

      开发完之后,测试和运维人员可以直接使用完全相同的环境来部署代码

      只要是开发测试过的代码就可以确保在生产环境无缝运行

      docker可以快速创建和删除容器,实现快速迭代,节约开发、测试及部署时间

    • 更高的利用资源

      运行docker不需要额外的虚拟化管理程序的支持

      docker是内核级的虚拟化,可以实现更高的性能,同时对资源的额外需求低

      与传统虚拟机方式相比,docker性能要提高1~2个数量级

    • 更轻松地迁移和扩展

      docker容器几乎可以在任意的平台运行,包括物理机、虚拟机、公有云、私有云、PC等

      支持主流的操作系统发行版本

      高兼容性可以让用户在不同的平台之间轻松的迁移应用

    • 更轻松的管理和更新

      使用dockerfile只需小的配置修改就可以替代大量的更新工作

      所有的修改都以增量的方式被发布和更新,从而实现自动化且高效的容器管理

    1.2.3 docker与虚拟机比较

    • docker容器启动快,启动和停止可实现秒级,相比传统虚拟机的分钟级要快很多
    • docker容器对系统资源需求少,一台主机上可以同时运行数千个Docker容器
    • docker通过类似git设计理念的操作来方便用户获取、分发和更新应用镜像,存储复用,增量更新
    • docker通过Dockerfile支持灵活的自动化创建和部署机制,可以提高工作效率,并标准化流程
    特性 容器 虚拟机
    启动速度 秒级 分钟级
    性能 接近原生 较好
    内存 MB级 GB级
    硬盘适应 MB级 GB级
    运行密度 单台主机支持上千个 单台主机支持几个
    隔离性 安全隔离 完全隔离
    迁移 优秀 一般

    1.3 Docker与虚拟化

    • Docker及其他容器技术都属于操作系统虚拟化范畴,操作系统虚拟化最大特点是不需要额外supervisor支持
    • 传统方式是在硬件层面实现虚拟化,需要有额外的虚拟机管理应用和虚拟机操作系统层
    • Docker容器是在操作系统层面实现虚拟化,直接复用本地主机的操作系统,因此更加轻量级

    2 Docker概念与使用

    2.1 docker三大核心概念

    2.1.1 镜像(Image)

    • Docker镜像(Image)相当于是一个root文件系统。
    • 如官方镜像ubuntu:16.04就包含完整一整套Ubuntu16.04最小系统的root文件系统

    2.1.2 容器(Container)

    • 镜像(Image)和容器(Container),就像是面向对象的程序设计中的类和实例一样
    • 镜像是静态的定义,容器是镜像运行的实体
    • 容器可以被创建、启动、停止、删除、暂停等

    2.1.3 仓库(Repository)

    • 用来保存镜像的仓库
    • 当我们构建好自己的镜像后需要放在仓库中。需要启动一个镜像时可以在仓库中下载下来

    2.2 Docker安装(CentOS)

    2.2.1 更换系统yum源

    # 查看操作系统内核版本
    [root@ccc ~]# uname -a
    Linux ccc 3.10.0-1127.el7.x86_64 #1 SMP Tue Mar 31 23:36:51 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
    # 备份原来的yum源
    [root@ccc ~]# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
    # 刷新yum源缓存
    [root@ccc ~]# yum makecache
    

    2.2.2 安装所需基础软件

    # 安装必要的一些系统工具
    [root@ccc ~]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
    # 下载新的CentOS-Base.repo 到 /etc/yum.repos.d/
    [root@ccc ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
    

    2.2.3 安装yum源

    # 安装yum源
    [root@ccc ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    

    2.2.4 安装并更新Docker-CE

    [root@ccc ~]# yum makecache fast
    [root@ccc ~]# yum -y install docker-ce
    

    2.2.5 启动并设置开机自启

    [root@ccc ~]# systemctl enable --now docker
    

    2.2.6 测试启动

    [root@ccc ~]# docker info
    [root@ccc ~]# systemctl status docker
    ● docker.service - Docker Application Container Engine
       Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
       Active: active (running) since 一 2020-11-30 21:57:57 CST; 1min 1s ago
    

    2.3 Docker安装(ubuntu)

    2.3.1 查看版本信息

    # 第一种方式
    root@alvin-test-os:~# uname -a
    # 第二种方式
    root@alvin-test-os:~# cat /proc/version
    

    2.3.2 更新系统

    root@alvin-test-os:~# apt-get update
    

    2.3.3 安装基础软件

    root@alvin-test-os:~# apt-get -y install apt-transport-https ca-certificates curl software-properties-common
    

    2.3.4 安装GPG证书

    root@alvin-test-os:~# curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - OK
    

    2.3.5 写入软件源信息

    root@alvin-test-os:~# sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
    

    2.3.6 更新并安装Docker-CE

    root@alvin-test-os:~# sudo apt-get -y update
    

    2.3.7 启动并检验

    root@alvin-test-os:~# docker version
    

    2.4 第一个Docker实例

    [root@ccc ~]# docker run -d --rm --name nginx -p 80:80 nginx
    Unable to find image 'nginx:latest' locally
    latest: Pulling from library/nginx
    bb79b6b2107f: Pull complete
    5a9f1c0027a7: Downloading [==============> ] 7.457MB/26.49MB
    5a9f1c0027a7: Downloading [======================> ] 12.17MB/26.49MB
    166a2418f7e8: Download complete
    1966ea362d23: Download complete
    

    3 使用Docker镜像

    3.1 获取镜像

    3.1.1 获取镜像pull

    • 下载镜像的格式:
    • docker pull [仓库的URL]/[命名空间名称]/[仓库名称]:[版本号]
    [root@ccc ~]# docker pull busybox:latest
    或
    [root@ccc ~]# docker pull docker.io/library/busybox:latest
    

    3.1.2 字段解释

    • URL:docker.io
    • 命名空间:library
    • 仓库名称:busybox
    • 版本号:latest
    [root@ccc ~]# docker pull nginx:1.17
    1.17: Pulling from library/nginx
    afb6ec6fdc1c: Pull complete 
    b90c53a0b692: Pull complete 
    11fa52a0fdc0: Pull complete 
    Digest: sha256:6fff55753e3b34e36e24e37039ee9eae1fe38a6420d8ae16ef37c92d1eb26699
    Status: Downloaded newer image for nginx:1.17
    docker.io/library/nginx:1.17
    

    3.1.3 补充

    • 使用docker pull命令下载会获取并输出镜像的各层信息
    • 当不同的镜像包括相同层的时候,本地仅存一份内容以减少存储空间

    3.2 查看镜像信息

    • 镜像主要包括镜像文件、镜像tag以及镜像详细信息等

    3.2.1 镜像列表images

    • docker images
    • docker images ls
    [root@ccc ~]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    nginx               latest              bc9a0695f571        5 days ago          133MB
    busybox             latest              dc3bacd8b5ea        6 days ago          1.23MB
    
    • REPOSITORY镜像来源:来自哪个仓库,默认来自:hub.docker.com
    • TAG镜像标签:如1.17、latest
    • IMAGE ID镜像ID:例如bc9a0695f571
    • CREATED时间段:如5 days ago
    • SIZE镜像大小:133MB

    3.2.2 images支持的选项

    • -a 显示所有的镜像(包括临时镜像文件)
    [root@ccc ~]# docker images -a
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    nginx               latest              bc9a0695f571        5 days ago          133MB
    busybox             latest              dc3bacd8b5ea        6 days ago          1.23MB
    nginx               1.17                9beeba249f3e        6 months ago        127MB
    
    • --digest=true|false 列出镜像的数字摘要值
    [root@ccc ~]# docker images --digests
    REPOSITORY          TAG                 DIGEST                                                                    IMAGE ID            CREATED             SIZE
    nginx               latest              sha256:6b1daa9462046581ac15be20277a7c75476283f969cb3a61c8725ec38d3b01c3   bc9a0695f571        5 days ago          133MB
    busybox             latest              sha256:9f1c79411e054199210b4d489ae600a061595967adb643cd923f8515ad8123d2   dc3bacd8b5ea        6 days ago          1.23MB
    nginx               1.17                sha256:6fff55753e3b34e36e24e37039ee9eae1fe38a6420d8ae16ef37c92d1eb26699   9beeba249f3e        6 months ago        127MB
    
    • -q 只显示镜像ID
    [root@ccc ~]# docker images -q
    bc9a0695f571
    dc3bacd8b5ea
    9beeba249f3e
    

    3.3 推送镜像push

    • docker push [镜像仓库URL]/[命名空间名称]/[仓库名称]:[版本号]
    [root@Centos7 docker]# docker push registry.cn-hangzhou.aliyuncs.com/alvinos/py15-nginx:1.19.2
    The push refers to repository [registry.cn-hangzhou.aliyuncs.com/alvinos/py15-nginx]
    908cf8238301: Pushed
    eabfa4cd2d12: Pushed
    60c688e8765e: Pushed
    f431d0917d41: Pushed
    07cab4339852: Pushed
    1.19.2: digest: sha256:794275d96b4ab96eeb954728a7bf11156570e8372ecd5ed0cbc7280313a27d19 size: 1362
    

    3.4 为镜像添加tag

    • docker tag [原镜像仓库url]/[原镜像命名空间]/[原镜像仓库名称]:[版本号] [新镜像仓库url]/[新镜像命名空间]/[新镜像仓库名称]:[版本号]
    [root@ccc ~]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    nginx               latest              bc9a0695f571        5 days ago          133MB
    busybox             latest              dc3bacd8b5ea        6 days ago          1.23MB
    nginx               1.17                9beeba249f3e        6 months ago        127MB
    [root@ccc ~]# docker tag busybox:latest mybusybox:latest
    [root@ccc ~]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    nginx               latest              bc9a0695f571        5 days ago          133MB
    mybusybox           latest              dc3bacd8b5ea        6 days ago          1.23MB
    busybox             latest              dc3bacd8b5ea        6 days ago          1.23MB
    nginx               1.17                9beeba249f3e        6 months ago        127MB
    

    3.5 查看详细信息inspect

    • docker inspect命令获取镜像的详细信息,包括PID、作者、架构等
    • -f 可以使用golang的模板获取所需信息
    [root@ccc ~]# docker inspect busybox
    [
        {
            "Id": "sha256:dc3bacd8b5ea796cea5d6070c8f145df9076f26a6bc1c8981fd5b176d37de843",
            "RepoTags": [
                "busybox:latest",
                "mybusybox:latest"
            ],
    ...
            "Metadata": {
                "LastTagTime": "2020-11-30T22:39:16.14474717+08:00"
            }
        }
    ]
    

    3.6 查看镜像历史history

    • 有些架构信息过长可以用--no-trunc选项来输出完整信息
    [root@ccc ~]# docker history busybox
    IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
    dc3bacd8b5ea        6 days ago          /bin/sh -c #(nop)  CMD ["sh"]                   0B                  
    <missing>           6 days ago          /bin/sh -c #(nop) ADD file:7f51bbea8802a227e…   1.23MB              
    

    3.7 搜索镜像

    3.7.1 搜索镜像search

    • docker search [所搜索的镜像名称]
    [root@ccc ~]# docker search python
    NAME                             DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
    python                           Python is an interpreted, interactive, objec…   5661                [OK]                
    django                           Django is a free web application framework, …   1021                [OK]                
    ...            
    
    • NAME:仓库名称
    • DESCRIPTION:描述
    • STARS:收藏次数
    • OFFICIAL:是否是官方镜像
    • AUTOMATED:是否是自构建的镜像

    3.7.2 search支持的选项

    • -f 过滤输出内容
    [root@ccc ~]# docker search python -f stars=300
    NAME                DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
    python              Python is an interpreted, interactive, objec…   5661                [OK]                
    django              Django is a free web application framework, …   1021                [OK] 
    
    • --limit 限制输出结果
    [root@ccc ~]# docker search python --limit 3
    NAME                     DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
    python                   Python is an interpreted, interactive, objec…   5661                [OK]                
    nikolaik/python-nodejs   Python with Node.js                             55                                      [OK]
    circleci/python          Python is an interpreted, interactive, objec…   41     
    
    • --no-trunc 不截断输出结果
    [root@ccc ~]# docker search python --limit 3 --no-trunc
    NAME                     DESCRIPTION                                                                                 STARS               OFFICIAL            AUTOMATED
    python                   Python is an interpreted, interactive, object-oriented, open-source programming language.   5661                [OK]                
    nikolaik/python-nodejs   Python with Node.js                                                                         55                                      [OK]
    circleci/python          Python is an interpreted, interactive, object-oriented, open-source programming language.   41
    

    3.8 删除rmi与清理prune镜像

    3.8.1 删除镜像rmi

    • 删除镜像rmi

    • docker rmi [镜像名称:版本号 | 镜像ID]

    • 参数:

      -f 强制删除

    [root@ccc ~]# docker rmi redis
    Untagged: redis:latest
    Untagged: 
    redis@sha256:5b98e32b58cdbf9f6b6f77072c4915d5ebec43912114031f37fa5fa25b032489
    
    # -f 强制删除镜像
    [root@ccc ~]# docker rmi -f redis
    Untagged: redis:latest
    Untagged:
    redis@sha256:5b98e32b58cdbf9f6b6f77072c4915d5ebec43912114031f37fa5fa25b032489
    

    3.8.2 清理镜像

    • 清理镜像prune

    • docker image prune [参数]

    • 参数:

      -a 删除所有未使用的镜像

      -f 强制删除

    # 查看原来的镜像
    [root@ccc ~]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    nginx               latest              bc9a0695f571        5 days ago          133MB
    busybox             latest              dc3bacd8b5ea        6 days ago          1.23MB
    mybusybox           latest              dc3bacd8b5ea        6 days ago          1.23MB
    nginx               1.17                9beeba249f3e        6 months ago        127MB
    # -a 删除所有的未被使用的镜像
    [root@ccc ~]# docker image prune -a
    WARNING! This will remove all images without at least one container associated to them.
    Are you sure you want to continue? [y/N] y
    Deleted Images:
    untagged: nginx:1.17
    ...
    
    # -f 强制删除镜像而不进行提示
    alvin@AlvindeMacBook-Pro: docker image prune -a -f
    Deleted Images:
    untagged: registry.cn-hangzhou.aliyuncs.com/alvinos/swoole:latest
    ...
    

    3.9 构建镜像commit

    • docker commit [参数] [容器ID | 容器名称:版本号]
    参数:
    -a : 维护者
    -m : 简介
    -p : 保存镜像时,镜像暂停运行
    

    3.10 保存镜像

    3.10.1 针对容器

    • export和import针对点是容器,将本机的容器导出为镜像包

    • export 针对容器保存镜像

      docker export [容器名或ID] > [压缩包名称]

      例如 docker export 3302aab7a252 > nginx.tar

    • import 针对export保存的压缩包

      docker import [压缩包名称] [镜像名称]:[版本号]

      • import 针对export保存的压缩包可以自定义镜像的名称
    # 使用export保存容器为镜像
    [root@ccc ~]# docker export daf9c3656be3 > nginx.tar 
    [root@ccc ~]# ll | grep nginx.tar 
    -rw-r--r-- 1 root root 135117824 9 月 24 20:51 nginx.tar
    
    # 使用import导入包为镜像
    [root@ccc ~]# docker import nginx.tar test/nginx:v1 
    sha256:02107323de1b074c5d2034b01eff855fec5922b45776c2721882d100ba6dd15b 
    [root@ccc ~]# docker images | grep test 
    test/nginx v1 02107323de1b 22 seconds ago 131MB
    

    3.10.2 针对镜像

    • save和load针对点是镜像,将本机的镜像导入、导出为镜像包

    • save针对镜像保存镜像

      docker save [镜像名或ID] > [压缩包名称]

      docker save -o [压缩包名称] [镜像名称或ID ...]

      • 当使用镜像ID保存镜像时导入时没有镜像名称。需docker tag自己添加
      • 可以同时保存多个镜像
    • load导入镜像

      docker load < [压缩包名称]

      • 仅针对save保存的压缩包
      • 不能自定义名称
      • save保存的更完整
    # 使用save保存镜像
    [root@ccc ~]# docker save 6858809bf669 > busybox.tar 
    [root@ccc ~]# ll | grep busy 
    -rw-r--r-- 1 root root 1458176 9 月 24 21:01 busybox.tar
    
    # 使用save保存多个镜像
    [root@ccc ~]# docker save -o test.tar busybox nginx:1.18.0 
    [root@ccc ~]# docker load < test.tar 
    Loaded image: busybox:latest 
    Loaded image: nginx:1.18.0
    
    # 使用load导入镜像
    [root@ccc ~]# docker load < busybox.tar 
    [root@ccc ~]# docker load -i busybox.tar 
    Loaded image ID: 
    sha256:6858809bf669cc5da7cb6af83d0fae838284d12e1be0182f92f6bd96559873e3 
    [root@ccc ~]# docker images | grep 685880 
    busybox latest 6858809bf669 2 weeks ago 1.23MB
    

    3.10.3 区别

    • export导出的镜像文件体积小于save保存的镜像
    • import可以指定镜像名称,load不可以
    • save可以将多个镜像打包到一个文件中,export不支持
    • import导入的镜像会丢失所有历史记录和元数据信息,无法回滚
    • load加载的镜像没有丢失镜像的历史,可以回滚

    4 仓库Repository

    • docker login [参数] [仓库URL]

    • docker login --username=xxx xxx.com

    • docker push [仓库URL]/[命名空间]/[仓库名称]:[版本号]

    5 使用Docker容器

    5.1 创建容器run

    5.1.1 格式

    • docker run [option] image [cmd]

    5.1.2 参数

    • 容器启动参数
    -d : 以守护进程的方式运行
    -p : 指定端口映射(格式:宿主主机端口:容器向外暴露的端口)
    	docker run -d -p 8899:80 nginx:1.19.2
    -P : 随机端口映射
    	docker run -d -P nginx:1.19.2
    --name: 指定容器的名称(同一台宿主主机上的docker名称不能重复)
        	将容器的名称解析到Docker DNS
    	docker run -d --name nginx_name -P nginx:1.19.2
    --rm:当一个容器结束了它的生命周期,就立即删除
    	docker run -d --rm --name nginx_rm nginx:1.19.2
    -v: 映射存储卷(可以映射文件及文件夹)
    	docker run -d -v /root/test:/usr/share/nginx/html -P nginx:1.19.2
    -i : 打开标准输出
    -t : 创建一个伪终端
    -e : 在容器内设置一个环境变量
    	docker run -d -e NGINX_NAME=nginx nginx:1.19.2
    
    [root@alvin-test-os ~]# docker run -d --name nginx -p 80:80 nginx 
    Unable to find image 'nginx:latest' locally 
    latest: Pulling from library/nginx 
    852e50cd189d: Pull complete 
    a29b129f4109: Pull complete 
    b3ddf1fa5595: Pull complete 
    c5df295936d3: Pull complete 
    232bf38931fc: Pull complete 
    Digest: sha256:c3a1592d2b6d275bef4087573355827b200b00ffc2d9849890a4f3aa2128c4ae 
    Status: Downloaded newer image for nginx:latest 
    6381d29d6e0ec3f6b01cf1aabb58b799ee88acf1a722e251807c9cb44e73a3e0 
    
    • docker 当中至少有一个应用程序运行在前台

    5.2 查看运行的容器ps

    5.2.1 格式

    • docker ps 查看正在运行的容器

    5.2.2 参数

    • -a 查看容器(包括已经停止了的容器)
    • -q 只查看容器ID
    [root@ccc ~]# docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                   NAMES
    140d8682230f        9beeba249f3e        "nginx -g 'daemon of…"   4 hours ago         Up 4 hours          0.0.0.0:32769->80/tcp   tender_cohen
    85113c409717        bc9a0695f571        "/docker-entrypoint.…"   4 hours ago         Up 4 hours          0.0.0.0:32768->80/tcp   suspicious_germain
    [root@ccc ~]# docker ps -a
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                   PORTS                   NAMES
    140d8682230f        9beeba249f3e        "nginx -g 'daemon of…"   4 hours ago         Up 4 hours               0.0.0.0:32769->80/tcp   tender_cohen
    85113c409717        bc9a0695f571        "/docker-entrypoint.…"   4 hours ago         Up 4 hours               0.0.0.0:32768->80/tcp   suspicious_germain
    a9d93f8e8df2        busybox             "sh"                     4 hours ago         Exited (0) 4 hours ago                           competent_hawking
    [root@ccc ~]# docker ps -q
    140d8682230f
    85113c409717
    

    5.3 停止容器stop

    • docker stop [容器名称 | 容器ID]
    • docker stop $(docker ps -q)

    5.4 进入容器

    5.4.1 attach

    docker attach [容器名或ID]

    • 多个窗口同时使用该命令进入该容器时,所有窗口都会同步显示
    • 如果一个窗口阻塞了,其他窗口也无法进行操作
    • 所有窗口退出时,容器结束
    [root@ccc ~]# docker attach nginx 
    127.0.0.1 - "GET / HTTP/1.1" 308 171 "-" "curl/7.59.0" 0.000 - .
    

    5.4.2 exec

    docker exec [参数] [容器名或ID] [命令]

    • 相当于在容器中执行一个命令
    [root@ccc ~]# docker exec -it nginx /bin/bash 
    nginx [ / ]$ 
    nginx [ / ]$
    

    5.4.3 nsenter

    • 需配合docker inspect使用
    [root@ccc ~]# nsenter --target $( docker inspect -f {{.State.Pid}} 
    nginxv1 ) --mount --uts --ipc --net --pid 
    mesg: ttyname failed: No such device 
    

    5.4.4 ssh

    • 使用Docker容器不建议使用ssh进入Docker容器内

    5.5 删除容器rm

    5.5.1 格式

    • docker rm
    [root@ccc ~]# docker rm nginx
    

    5.5.2 强制删除-f

    [root@ccc ~]# docker rm -f nginx
    nginx
    

    5.6 复制

    5.6.1 容器-->宿主主机

    • docker cp [容器ID:容器内文件路径] 宿主主机路径
    [root@ccc ~]# docker cp 726b695a337c:/opt/start . 
    [root@ccc ~]# ls | grep start 
    Start
    

    5.6.2 宿主主机-->容器

    • docker cp 宿主主机路径 [容器ID:容器内文件路径]
    [root@ccc ~]# docker cp start 726b695a337c:/root 
    [root@ccc ~]# docker exec 726b695a337c ls /root 
    start
    

    6 Docker网络

  • 相关阅读:
    Python3.7.1学习(三)求两个list的差集、并集与交集
    Python3.7.1学习(二)使用schedule模块定时执行任务
    Python3.7.1学习(一):redis的连接和简单使用
    requests保存图片
    requests模拟登陆的三种方式
    requests模块使用代理
    requests模块发送带headers的Get请求和带参数的请求
    python3.7.1安装Scrapy爬虫框架
    python-生成器
    python-迭代器
  • 原文地址:https://www.cnblogs.com/caojiaxin/p/14070911.html
Copyright © 2020-2023  润新知