目录
- 一、简介
- 1、docker架构
- 2、docker的概念
- 二、docker的安装和管理
- 1、docker安装
- 2、docker配置阿里云镜像加速
- 3、基础命令
一、简介
参考 https://www.cnblogs.com/linuxk/p/8984242.html
1、docker架构
Docker 使用客户端-服务器 (C/S) 架构模式,使用远程API来管理和创建Docker容器。
Docker 容器通过 Docker 镜像来创建。
容器与镜像的关系类似于面向对象编程中的对象与类。
Docker 面向对象
容器 对象
镜像 类
Docker 镜像(Images) Docker 镜像是用于创建 Docker 容器的模板。
Docker 容器(Container) 容器是独立运行的一个或一组应用。
Docker 客户端(Client) Docker 客户端通过命令行或者其他工具使用 Docker API (https://docs.docker.com/reference/api/docker_remote_api) 与 Docker 的守护进程通信。
Docker 主机(Host) 一个物理或者虚拟的机器用于执行 Docker 守护进程和容器。
Docker 仓库(Registry) Docker 仓库用来保存镜像,可以理解为代码控制中的代码仓库。Docker Hub(https://hub.docker.com) 提供了庞大的镜像集合供使用。
Docker Machine Docker Machine是一个简化Docker安装的命令行工具,通过一个简单的命令行即可在相应的平台上安装Docker,比如VirtualBox、 Digital Ocean、Microsoft Azure。
Docker项目的目标是实现轻量级的操作系统虚拟化解决方案。Docker的基础是linux容器(LXC)等技术。
2、docker的概念
镜像:是一个只读的模板,类似于安装系统用到的那个iso文件,我们通过镜像来完成各种应用的部署。镜像可以用来创建Docker容器
容器:镜像类似于操作系统,而容器类似于虚拟机本身。它可以被启动、开始、停止、删除等操作,每个容器都是相互隔离的。可以把容器看做是一个简易版的linux环境(包括root用户权限、进程空间、用户空间和网络空间等)和运行在其中的应用程序。
仓库:存放镜像的一个场所,仓库分为公开仓库和私有仓库。 最大的公开仓库是Docker hub(hub.docker.com),国内公开仓库(dockerpool.com)
二、docker的安装和管理
1、docker安装
依赖环境 Centos 7 3.10内核
Docker EE
Docker EE由公司支持,可在经过认证的操作系统和云提供商中使用,并可运行来自Docker Store的、经过认证的容器和插件。
Docker EE提供三个服务层次:
Docker CE
Docker CE是免费的Docker产品的新名称,Docker CE包含了完整的Docker平台,非常适合开发人员和运维团队构建容器APP。事实上,Docker CE 17.03,可理解为Docker 1.13.1的Bug修复版本。因此,从Docker 1.13升级到Docker CE 17.03风险相对是较小的。
大家可前往Docker的RELEASE log查看详情https://github.com/docker/docker/releases 。
Docker公司认为,Docker CE和EE版本的推出为Docker的生命周期、可维护性以及可升级性带来了巨大的改进。
此处选择docker-ce来学习。
#获取阿里epel源
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
--2018-12-03 21:39:41-- https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 157.255.30.119, 157.255.30.121, 157.255.30.120, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|157.255.30.119|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2640 (2.6K) [application/octet-stream]
Saving to: ‘docker-ce.repo’
100%[===========================>] 2,640 --.-K/s in 0s
2018-12-03 21:39:42 (21.0 MB/s) - ‘docker-ce.repo’ saved [2640/2640]
[[email protected] yum.repos.d]# yum makecache
[[email protected] yum.repos.d]# yum install docker-ce -y
#启动docker
[[email protected] yum.repos.d]# systemctl start docker
[[email protected] yum.repos.d]# ps -ef|grep docker
root 1709 1 1 21:43 ? 00:00:00 /usr/bin/dockerd -H unix://
root 1723 1709 0 21:43 ? 00:00:00 containerd --config /var/run/docker/containerd/containerd.toml --log-level info
root 1866 1263 0 21:44 pts/0 00:00:00 grep --color=auto docker
注意:
官方软件源默认启用了最新的软件,您可以通过编辑软件源的方式获取各个版本的软件包。例如官方并没有将测试版本的软件源置为可用,你可以通过以下方式开启。同理可以开启各种测试版本等。
vim /etc/yum.repos.d/docker-ce.repo
将 [docker-ce-test] 下方的 enabled=0 修改为 enabled=1
安装指定版本的Docker-CE:
Step 1: 查找Docker-CE的版本:
yum list docker-ce.x86_64 --showduplicates | sort -r
Loading mirror speeds from cached hostfile
Loaded plugins: branch, fastestmirror, langpacks
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos @docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
Available Packages
Step2 : 安装指定版本的Docker-CE: (VERSION 例如上面的 17.03.0.ce.1-1.el7.centos)
2、docker配置阿里云镜像加速
默认配置文件在/etc/docker/内,默认没有需要自己创建
1)、登录阿里云容器镜像加速
[[email protected] yum.repos.d]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://xhszfb4i.mirror.aliyuncs.com"]
#每个人的不一样
}
[[email protected] yum.repos.d]# systemctl restart docker
3、基础命令
1)查看版本和详情
查看版本
[[email protected] yum.repos.d]# docker version
Client:
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:48:22 2018
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:19:08 2018
OS/Arch: linux/amd64
Experimental: false
查看详情
[[email protected] yum.repos.d]# docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 18.09.0
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: c4446665cb9c30056f4998ed953e6d4ff22c7c39
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-862.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.779GiB
Name: node1
ID: YDLV:VFIA:6UIH:MHQE:PVYX:BSCR:4DCG:XSEF:NPSK:VSES:NM2D:YOD2
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://xhszfb4i.mirror.aliyuncs.com/
Live Restore Enabled: false
Product License: Community Engine
2)常用命令含义
docker search 搜索镜像
docker pull 拉取镜像
docker images 查看本地镜像
docker create 创建容器
docker start 开启多个停止的容器
docker run 在一个新容器里面执行命令
docker attach 容器隔离后重新连接
docker ps 查看容器列表
docker logs 查看容器日志
docker restart 重启容器
docker stop 停止容器 相当于kill -15
docker kill kill容器 相当于kill -9
docker rm 删除容器
docker rmi 删除镜像 docker image rm
3)docker pull
hub.docker.com 搜索镜像拉取,此处以nginx1.14.1-alpine版本为例
#拉取
[[email protected] ~]# docker pull nginx:1.14.1-alpine
1.14.1-alpine: Pulling from library/nginx
4fe2ade4980c: Pull complete
c691664ebb08: Pull complete
a6f6a50701b6: Pull complete
5980ba3b5a39: Pull complete
Digest: sha256:3c1380fd5f6f0e4c468a922ed6331831e60cea9db317b8ac4a8ad36335e53bbd
Status: Downloaded newer image for nginx:1.14.1-alpine
#查看镜像 使用docker images 或者 docker image ls
[[email protected] ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx 1.14.1-alpine 77bae8d00654 3 weeks ago 17.7MB
#显示完整的镜像 ID默认是前12位
#[[email protected] ~]# docker image ls --no-trunc
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx 1.14.1-alpine sha256:77bae8d0065423e2338884d3698ef5ff9de8dec05a55dc81cf48ae9e78008b3f 3 weeks ago 17.7MB
4)docker create
创建
docker container create 或者docker create
创建后直接启动
docker run
容器的开始 停止 暂停
docker start stop pause
5)top
docker container top
列出所有容器(不显示停止状态的容器) docker ps -a 会显示处于停止状态的容器
docker ps /docker container ls
6)docker run
创建并启动容器
#查看docker run用法
[[email protected] ~]# docker run --help
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
开启一个busybox容器,如果本地没有该镜像默认会从dockerhub拉取,默认拉取最新版本,latest版本
busybox介绍
Busybox是一个开源项目,遵循GPL v2协议。Busybox将众多的UNIX命令集合进一个很小的可执行程序中,可以用来替代GNU fileutils、shellutils等工具集。Busybox中各种命令与相应的GNU工具相比,所能提供的选项比较少,但是也足够一般的应用了。Busybox主要用于嵌入式系统。
#创建并启动容器
[[email protected] ~]# docker run --name b1 -it busybox:latest
Unable to find image ‘busybox:latest‘ locally
latest: Pulling from library/busybox
90e01955edcd: Pull complete
Digest: sha256:2a03a6059f21e150ae84b0973863609494aad70f0a80eaeb64bddd8d92465812
Status: Downloaded newer image for busybox:latest
/ #
--name指定容器名称 -i表示让容器的标准输入打开,-t表示分配一个伪终端,要把-i -t 放到镜像名字前面
#执行命令及验证
#进入查看httpd帮助命令
/ # httpd -h
httpd: option requires an argument -- h
BusyBox v1.29.3 (2018-10-01 22:37:18 UTC) multi-call binary.
Usage: httpd [-ifv[v]] [-c CONFFILE] [-p [IP:]PORT] [-u USER[:GRP]] [-r REALM] [-h HOME]
or httpd -d/-e/-m STRING
Listen for incoming HTTP requests
-i Inetd mode
-f Don‘t daemonize
-v[v] Verbose
-p [IP:]PORT Bind to IP:PORT (default *:80)
-u USER[:GRP] Set uid/gid after binding to port
-r REALM Authentication Realm for Basic Authentication
-h HOME Home directory (default .)
-c FILE Configuration file (default {/etc,HOME}/httpd.conf)
-m STRING MD5 crypt STRING
-e STRING HTML encode STRING
-d STRING URL decode STRING
#创建首页文件,测试容器
/ # mkdir /data/html -p
/ # echo "who let the dogs out!!!">/data/html/index.html
/ # httpd -f -h /data/html
#复制一个终端,使用docker inspect 容器名 查看容器详情,找到IP地址
[[email protected] ~]# docker inspect b1
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "df5b7970b3a8455e8f4c8067d5558fd3d12023950455c1106ec798db6fed9d66",
"EndpointID": "d8fd69764f7a1cffa3b023427178c6e4fd8712c56447897e784a5606c54e9e78",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
#在此刻知道该容器网络模式为bridge(默认),IP地址为172.17.0.2,网关为172.17.0.1
#测试该网络的httpd服务
[[email protected] ~]# curl 172.17.0.2
who let the dogs out!!!
#测试发现容器httpd服务正常开启
#ps查看系统进程为1的是sh命令 如果退出 容器就会终止运行 httpd也会停止
/ # ps
PID USER TIME COMMAND
1 root 0:00 sh
10 root 0:00 ps
#停止
/ # exit
7)ocker container start
#开启关闭的容器
[[email protected] ~]# docker container start -i -a b1
/ #
#另开一个终端查看
[[email protected] ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c421b489234e busybox:latest "sh" 10 minutes ago Up 15 seconds b1
启动容器时 docker daemon先从本地获取 本地不存在时 从Registry中下载并保持本地 默认是dockerhub 可以指定
获取镜像
docker pull
8)docker kill /stop
可以适用docker stop 和docker kill 来停止容器 区别就是 stop = kill -15 kill = kill -9
[[email protected] ~]# docker kill b1
b1
[[email protected] ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9)docker inspect
docker inspect 容器名 查看容器详情
docker image inspect 镜像ID查看镜像详情
10)docker logs
查看容器日志
[[email protected] ~]# docker logs b1
/ # httpd -h
httpd: option requires an argument -- h
BusyBox v1.29.3 (2018-10-01 22:37:18 UTC) multi-call binary.
Usage: httpd [-ifv[v]] [-c CONFFILE] [-p [IP:]PORT] [-u USER[:GRP]] [-r REALM] [-h HOME]
or httpd -d/-e/-m STRING
Listen for incoming HTTP requests
-i Inetd mode
-f Don‘t daemonize
-v[v] Verbose
-p [IP:]PORT Bind to IP:PORT (default *:80)
-u USER[:GRP] Set uid/gid after binding to port
-r REALM Authentication Realm for Basic Authentication
-h HOME Home directory (default .)
-c FILE Configuration file (default {/etc,HOME}/httpd.conf)
-m STRING MD5 crypt STRING
-e STRING HTML encode STRING
-d STRING URL decode STRING
/ # mkdir /data/html -p
/ # echo "who lte the dogs out!!!">/data/html/index.html
/ # httpd -f -h /data/html
^C
/ # ps
PID USER TIME COMMAND
1 root 0:00 sh
10 root 0:00 ps
/ # exit
11)docker exec
进入容器(推荐 使用 exec)
#开启redis容器
[[email protected] ~]# docker run --name redis -d redis:4-alpine3.8
Unable to find image ‘redis:4-alpine3.8‘ locally
4-alpine3.8: Pulling from library/redis
4fe2ade4980c: Already exists
fb758dc2e038: Pull complete
989f7b0c858b: Pull complete
d5318f13abaa: Pull complete
3521559474dd: Pull complete
add04b113886: Pull complete
Digest: sha256:2953e537b8eaa5120855285497d4f936d9f02a16480a9d76e8ba014dc3998704
Status: Downloaded newer image for redis:4-alpine3.8
141343b29efa37b4fe1f17bd6b44b8ce0125b6aab1b4f0afc3b131ceddee6566
#进入容器
[[email protected] ~]# docker exec -it redis /bin/sh
/data # ps
PID USER TIME COMMAND
1 redis 0:00 redis-server
12 root 0:00 /bin/sh
17 root 0:00 ps
12)docker commit
镜像的生成途径
1、docker file(后续)
2、基于容器制作
启动容器后部署需要的修改后 commit
Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
Options:
-a, --author string Author (e.g., "John Hannibal Smith <[email protected]>")
-c, --change list Apply Dockerfile instruction to the created image
-m, --message string Commit message #提交信息
-p, --pause Pause container during commit (default true) #暂停 防止数据异常
busybox举例
[[email protected] ~]# docker run --name b2 -it busybox
/ # ls
bin dev etc home proc root sys tmp usr var
/ # mkdir /data/html -p
/ # echo "commit test">/data/html/index.html
#复制一个终端
[[email protected] ~]# docker commit -p b2
sha256:8a3222f2654582298c41e7975b59bc36a059ff6bc344783dd7ebb6f84cb3a044
#此时制作的镜像无标签
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 8a3222f26545 About a minute ago 1.15MB
nginx 1.14.1-alpine 77bae8d00654 3 weeks ago 17.7MB
redis 4-alpine3.8 05097a3a0549 2 months ago 30MB
busybox latest 59788edf1f3e 2 months ago 1.15MB
13)docker tag
给镜像 打标签
Usage: docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
#建议先创建dockerhub账户,仓库 我的仓库 名字是xiaobai20201 所以这样命名
[[email protected] ~]# docker tag 8a3222f26545 xiaobai20201/httpd:v0.1-1
[[email protected] ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
xiaobai20201/httpd v0.1-1 8a3222f26545 3 minutes ago 1.15MB
nginx 1.14.1-alpine 77bae8d00654 3 weeks ago 17.7MB
redis 4-alpine3.8 05097a3a0549 2 months ago 30MB
busybox latest 59788edf1f3e 2 months ago 1.15MB
#一个镜像可以多个标签
[[email protected] ~]# docker tag xiaobai20201/httpd:v0.1-1 xiaobai20201/httpd:latest
[[email protected] ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
xiaobai20201/httpd latest 8a3222f26545 6 minutes ago 1.15MB
xiaobai20201/httpd v0.1-1 8a3222f26545 6 minutes ago 1.15MB
nginx 1.14.1-alpine 77bae8d00654 3 weeks ago 17.7MB
redis 4-alpine3.8 05097a3a0549 2 months ago 30MB
busybox latest 59788edf1f3e 2 months ago 1.15MB
#删除一个标签 如果镜像还有另外的标签 镜像不会被删除 类似硬链接
#验证刚才操作
[[email protected] ~]# docker run --name t1 -it xiaobai20201/httpd:latest
/ # ls
bin data dev etc home proc root sys tmp usr var
/ # ls /data/html/index.html -l
-rw-r--r-- 1 root root 12 Dec 3 14:52 /data/html/index.html
#修改容器启动镜像默认命令
14)docker inspect
查看详情
#查看镜像配置情况 ,查看默认启动容器的命令
[[email protected] ~]# docker inspect b2
......
"Cmd": [
"sh"
],
......
#查看redis默认启动命令
[[email protected] ~]# docker inspect redis
"Cmd": [
"redis-server"
],
[[email protected] ~]# docker commit -h
Flag shorthand -h has been deprecated, please use --help
Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
Create a new image from a container‘s changes
Options:
-a, --author string Author (e.g., "John Hannibal Smith <[email protected]>") #类似备注
-c, --change list Apply Dockerfile instruction to the created image #修改CMD命令
-m, --message string Commit message #提交信息
-p, --pause Pause container during commit (default true) #暂停,防止丢失 数据
#根据b1 -c 修改默认命令 -p 暂停 基于b1 制作 制作后的标签
[[email protected] ~]# docker commit -a "white <[email protected]>" -c ‘CMD ["/bin/httpd","-f","-h","/data/html"]‘ -p b1 xiaobai20201/httpd:v0.2
sha256:74606456efe3ef351549c8aae7a39f593faa96541e4158154c02d7b8c7b65ac4
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xiaobai20201/httpd v0.2 74606456efe3 10 seconds ago 1.15MB
xiaobai20201/httpd latest 8a3222f26545 15 minutes ago 1.15MB
xiaobai20201/httpd v0.1-1 8a3222f26545 15 minutes ago 1.15MB
nginx 1.14.1-alpine 77bae8d00654 3 weeks ago 17.7MB
redis 4-alpine3.8 05097a3a0549 2 months ago 30MB
busybox latest 59788edf1f3e 2 months ago 1.15MB
#运行并测试v0.2
[[email protected] ~]# docker run --name t2 xiaobai20201/httpd:v0.2
#由于是非交互式 且默认运行为httpd -f 在前台运行 所以无信息
#复制终端测试
[[email protected] ~]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5d05f54dfae0 xiaobai20201/httpd:v0.2 "/bin/httpd -f -h /d…" 44 seconds ago Up 42 seconds t2
141343b29efa redis:4-alpine3.8 "docker-entrypoint.s…" 37 minutes ago Up 37 minutes 6379/tcp redis
#使用docker inspect 查看ip信息 然后curl
[[email protected] ~]# docker inspect t2
......
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
[[email protected] ~]# curl 172.17.0.3
who let the dogs out!!!
15)docker push
docker默认推拉的都是从 https://hub.docker.com/
进入dockerhub登录创建容器仓库
推送镜像 确保dockerhub 的仓库名称一样
REPOSITORY TAG IMAGE ID CREATED SIZE
xiaobai20201/httpd v0.2 74606456efe3 7 minutes ago 1.15MB
xiaobai20201/httpd latest 8a3222f26545 23 minutes ago 1.15MB
xiaobai20201/httpd v0.1-1 8a3222f26545 23 minutes ago 1.15MB
nginx 1.14.1-alpine 77bae8d00654 3 weeks ago 17.7MB
redis 4-alpine3.8 05097a3a0549 2 months ago 30MB
busybox latest 59788edf1f3e 2 months ago 1.15MB
先登录hub仓库 否则没有权限
[[email protected] ~]# docker login -u xiaobai20201
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
#推送
[[email protected] ~]# dockr push xiaobai20201/httpd
-bash: dockr: command not found
[[email protected] ~]# docker push xiaobai20201/httpd
The push refers to repository [docker.io/xiaobai20201/httpd]
38dff1cc6640: Pushed
8a788232037e: Mounted from library/busybox
latest: digest: sha256:91134d63e1175bc725ddf4cc2ff88eda4972b0cb5b71a2e0e44f9c2dea2aa3de size: 734
38dff1cc6640: Layer already exists
8a788232037e: Layer already exists
v0.1-1: digest: sha256:91134d63e1175bc725ddf4cc2ff88eda4972b0cb5b71a2e0e44f9c2dea2aa3de size: 734
5149fd1bda4b: Pushed
8a788232037e: Layer already exists
v0.2: digest: sha256:c4d8fe04d29917daf378a1d4012294dd3e4cc0c280bba80726ca05c7c73b73c5 size: 734
回到dockerhub刷新 查看
16)docker save
打包镜像
[[email protected] ~]# docker save -o httpd.tar.gz xiaobai20201/httpd:v0.2 xiaobai20201/httpd:v0.1-1
[[email protected] ~]# ls -l
total 1372
-rw-------. 1 root root 1580 Dec 2 10:08 anaconda-ks.cfg
-rw-------. 1 root root 1399296 Dec 3 23:22 httpd.tar.gz
#-o 指定名称
#发送到node2主机
[[email protected] ~]# scp ./httpd.tar.gz [email protected]:/tmp
[email protected]‘s password:
httpd.tar.gz 100% 1367KB 62.4MB/s 00:00
17)docker load
导入镜像
#node2把从node1接收到的 镜像还原到本机 (node2已经安装了docker)
[[email protected] ~]# cp /tmp/httpd.tar.gz .
[[email protected] ~]# docker load -i httpd.tar.gz #-i 指定文件
8a788232037e: Loading layer 1.37MB/1.37MB
5149fd1bda4b: Loading layer 5.12kB/5.12kB
Loaded image: xiaobai20201/httpd:v0.2
38dff1cc6640: Loading layer 5.12kB/5.12kB
Loaded image: xiaobai20201/httpd:v0.1-1
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xiaobai20201/httpd v0.2 74606456efe3 18 minutes ago 1.15MB
xiaobai20201/httpd v0.1-1 8a3222f26545 33 minutes ago 1.15MB
原文地址:https://www.cnblogs.com/wlbl/p/10061864.html