CentOS7 Docker安装操作以及基本命令

来源:互联网 发布:plc与单片机区别 编辑:程序博客网 时间:2024/05/14 11:28

CentOS7 Docker安装操作以及基本命令 标题


1.安装docker


yum -y install docker-io

[root@localhost ~]# yum -y install docker-io Loaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.btte.net * updates: mirrors.163.comResolving Dependencies--> Running transaction check---> Package docker.x86_64 2:1.12.6-28.git1398f24.el7.centos will be installed--> Processing Dependency: docker-common = 2:1.12.6-28.git1398f24.el7.centos for package: 2:docker-1.12.6-28.git1398f24.el7.centos.x86_64--> Processing Dependency: docker-client = 2:1.12.6-28.git1398f24.el7.centos for package: 2:docker-1.12.6-28.git1398f24.el7.centos.x86_64--> Processing Dependency: oci-systemd-hook >= 1:0.1.4-9 for package: 2:docker-1.12.6-28.git1398f24.el7.centos.x86_64--> Processing Dependency: oci-register-machine >= 1:0-3.10 for package: 2:docker-1.12.6-28.git1398f24.el7.centos.x86_64--> Processing Dependency: container-selinux >= 2:2.12-2 for package: 2:docker-1.12.6-28.git1398f24.el7.centos.x86_64--> Processing Dependency: skopeo-containers for package: 2:docker-1.12.6-28.git1398f24.el7.centos.x86_64--> Running transaction check---> Package container-selinux.noarch 2:2.12-2.gite7096ce.el7 will be installed--> Processing Dependency: policycoreutils >= 2.5-11 for package: 2:container-selinux-2.12-2.gite7096ce.el7.noarch---> Package docker-client.x86_64 2:1.12.6-28.git1398f24.el7.centos will be installed---> Package docker-common.x86_64 2:1.12.6-28.git1398f24.el7.centos will be installed---> Package oci-register-machine.x86_64 1:0-3.11.gitdd0daef.el7 will be installed---> Package oci-systemd-hook.x86_64 1:0.1.7-2.git2788078.el7 will be installed---> Package skopeo-containers.x86_64 1:0.1.19-1.el7 will be installed--> Running transaction check---> Package policycoreutils.x86_64 0:2.2.5-20.el7 will be updated--> Processing Dependency: policycoreutils = 2.2.5-20.el7 for package: policycoreutils-python-2.2.5-20.el7.x86_64---> Package policycoreutils.x86_64 0:2.5-11.el7_3 will be an update--> Processing Dependency: libsepol >= 2.5-6 for package: policycoreutils-2.5-11.el7_3.x86_64--> Processing Dependency: libselinux-utils >= 2.5-6 for package: policycoreutils-2.5-11.el7_3.x86_64--> Processing Dependency: libsepol.so.1(LIBSEPOL_1.1)(64bit) for package: policycoreutils-2.5-11.el7_3.x86_64--> Processing Dependency: libsepol.so.1(LIBSEPOL_1.0)(64bit) for package: policycoreutils-2.5-11.el7_3.x86_64--> Processing Dependency: libsemanage.so.1(LIBSEMANAGE_1.1)(64bit) for package: policycoreutils-2.5-11.el7_3.x86_64--> Running transaction check---> Package libselinux-utils.x86_64 0:2.2.2-6.el7 will be updated---> Package libselinux-utils.x86_64 0:2.5-6.el7 will be an update--> Processing Dependency: libselinux(x86-64) = 2.5-6.el7 for package: libselinux-utils-2.5-6.el7.x86_64---> Package libsemanage.x86_64 0:2.1.10-18.el7 will be updated--> Processing Dependency: libsemanage = 2.1.10-18.el7 for package: libsemanage-python-2.1.10-18.el7.x86_64---> Package libsemanage.x86_64 0:2.5-5.1.el7_3 will be an update---> Package libsepol.x86_64 0:2.1.9-3.el7 will be updated---> Package libsepol.x86_64 0:2.5-6.el7 will be an update---> Package policycoreutils-python.x86_64 0:2.2.5-20.el7 will be updated---> Package policycoreutils-python.x86_64 0:2.5-11.el7_3 will be an update--> Processing Dependency: setools-libs >= 3.3.8-1 for package: policycoreutils-python-2.5-11.el7_3.x86_64--> Running transaction check---> Package libselinux.x86_64 0:2.2.2-6.el7 will be updated--> Processing Dependency: libselinux = 2.2.2-6.el7 for package: libselinux-python-2.2.2-6.el7.x86_64---> Package libselinux.x86_64 0:2.5-6.el7 will be an update---> Package libsemanage-python.x86_64 0:2.1.10-18.el7 will be updated---> Package libsemanage-python.x86_64 0:2.5-5.1.el7_3 will be an update---> Package setools-libs.x86_64 0:3.3.7-46.el7 will be updated---> Package setools-libs.x86_64 0:3.3.8-1.1.el7 will be an update--> Running transaction check---> Package libselinux-python.x86_64 0:2.2.2-6.el7 will be updated---> Package libselinux-python.x86_64 0:2.5-6.el7 will be an update--> Processing Conflict: libsemanage-2.5-5.1.el7_3.x86_64 conflicts selinux-policy-base < 3.13.1-66--> Restarting Dependency Resolution with new changes.--> Running transaction check---> Package selinux-policy-targeted.noarch 0:3.13.1-60.el7 will be updated---> Package selinux-policy-targeted.noarch 0:3.13.1-102.el7_3.16 will be an update--> Processing Dependency: selinux-policy = 3.13.1-102.el7_3.16 for package: selinux-policy-targeted-3.13.1-102.el7_3.16.noarch--> Processing Dependency: selinux-policy = 3.13.1-102.el7_3.16 for package: selinux-policy-targeted-3.13.1-102.el7_3.16.noarch--> Running transaction check---> Package selinux-policy.noarch 0:3.13.1-60.el7 will be updated---> Package selinux-policy.noarch 0:3.13.1-102.el7_3.16 will be an update--> Processing Conflict: libselinux-2.5-6.el7.x86_64 conflicts systemd < 219-20--> Restarting Dependency Resolution with new changes.--> Running transaction check---> Package systemd.x86_64 0:219-19.el7 will be updated--> Processing Dependency: systemd = 219-19.el7 for package: systemd-python-219-19.el7.x86_64--> Processing Dependency: systemd = 219-19.el7 for package: systemd-sysv-219-19.el7.x86_64---> Package systemd.x86_64 0:219-30.el7_3.9 will be an update--> Processing Dependency: systemd-libs = 219-30.el7_3.9 for package: systemd-219-30.el7_3.9.x86_64--> Running transaction check---> Package systemd-libs.x86_64 0:219-19.el7 will be updated--> Processing Dependency: systemd-libs = 219-19.el7 for package: libgudev1-219-19.el7.x86_64---> Package systemd-libs.x86_64 0:219-30.el7_3.9 will be an update---> Package systemd-python.x86_64 0:219-19.el7 will be updated---> Package systemd-python.x86_64 0:219-30.el7_3.9 will be an update---> Package systemd-sysv.x86_64 0:219-19.el7 will be updated---> Package systemd-sysv.x86_64 0:219-30.el7_3.9 will be an update--> Running transaction check---> Package libgudev1.x86_64 0:219-19.el7 will be updated---> Package libgudev1.x86_64 0:219-30.el7_3.9 will be an update--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================================================================================================================ Package                                                        Arch                                          Version                                                                  Repository                                      Size============================================================================================================================================================================================================================================Installing: docker                                                         x86_64                                        2:1.12.6-28.git1398f24.el7.centos                                        extras                                          14 MUpdating: selinux-policy-targeted                                        noarch                                        3.13.1-102.el7_3.16                                                      updates                                        6.4 M systemd                                                        x86_64                                        219-30.el7_3.9                                                           updates                                        5.2 MInstalling for dependencies: container-selinux                                              noarch                                        2:2.12-2.gite7096ce.el7                                                  extras                                          28 k docker-client                                                  x86_64                                        2:1.12.6-28.git1398f24.el7.centos                                        extras                                         3.2 M docker-common                                                  x86_64                                        2:1.12.6-28.git1398f24.el7.centos                                        extras                                          75 k oci-register-machine                                           x86_64                                        1:0-3.11.gitdd0daef.el7                                                  extras                                         1.0 M oci-systemd-hook                                               x86_64                                        1:0.1.7-2.git2788078.el7                                                 extras                                          30 k skopeo-containers                                              x86_64                                        1:0.1.19-1.el7                                                           extras                                         7.7 kUpdating for dependencies: libgudev1                                                      x86_64                                        219-30.el7_3.9                                                           updates                                         77 k libselinux                                                     x86_64                                        2.5-6.el7                                                                base                                           161 k libselinux-python                                              x86_64                                        2.5-6.el7                                                                base                                           234 k libselinux-utils                                               x86_64                                        2.5-6.el7                                                                base                                           151 k libsemanage                                                    x86_64                                        2.5-5.1.el7_3                                                            updates                                        144 k libsemanage-python                                             x86_64                                        2.5-5.1.el7_3                                                            updates                                        104 k libsepol                                                       x86_64                                        2.5-6.el7                                                                base                                           288 k policycoreutils                                                x86_64                                        2.5-11.el7_3                                                             updates                                        841 k policycoreutils-python                                         x86_64                                        2.5-11.el7_3                                                             updates                                        445 k selinux-policy                                                 noarch                                        3.13.1-102.el7_3.16                                                      updates                                        414 k setools-libs                                                   x86_64                                        3.3.8-1.1.el7                                                            base                                           612 k systemd-libs                                                   x86_64                                        219-30.el7_3.9                                                           updates                                        369 k systemd-python                                                 x86_64                                        219-30.el7_3.9                                                           updates                                        110 k systemd-sysv                                                   x86_64                                        219-30.el7_3.9                                                           updates                                         64 kTransaction Summary============================================================================================================================================================================================================================================Install  1 Package  (+ 6 Dependent packages)Upgrade  2 Packages (+14 Dependent packages)Total size: 34 MTotal download size: 19 MDownloading packages:(1/7): container-selinux-2.12-2.gite7096ce.el7.noarch.rpm                                                                                                                                                            |  28 kB  00:00:00     (2/7): docker-common-1.12.6-28.git1398f24.el7.centos.x86_64.rpm                                                                                                                                                      |  75 kB  00:00:00     (3/7): skopeo-containers-0.1.19-1.el7.x86_64.rpm                                                                                                                                                                     | 7.7 kB  00:00:00     (4/7): oci-systemd-hook-0.1.7-2.git2788078.el7.x86_64.rpm                                                                                                                                                            |  30 kB  00:00:00     (5/7): oci-register-machine-0-3.11.gitdd0daef.el7.x86_64.rpm                                                                                                                                                         | 1.0 MB  00:00:01     (6/7): docker-1.12.6-28.git1398f24.el7.centos.x86_64.rpm                                                                                                                                                             |  14 MB  00:00:01     (7/7): docker-client-1.12.6-28.git1398f24.el7.centos.x86_64.rpm                                                                                                                                                      | 3.2 MB  00:00:02     --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Total                                                                                                                                                                                                       7.8 MB/s |  19 MB  00:00:02     Running transaction checkRunning transaction testTransaction test succeededRunning transaction  Updating   : libsepol-2.5-6.el7.x86_64                                                                                                                                                                                               1/39   Updating   : libselinux-2.5-6.el7.x86_64                                                                                                                                                                                             2/39   Updating   : systemd-libs-219-30.el7_3.9.x86_64                                                                                                                                                                                      3/39   Updating   : systemd-219-30.el7_3.9.x86_64                                                                                                                                                                                           4/39   Updating   : libsemanage-2.5-5.1.el7_3.x86_64                                                                                                                                                                                        5/39   Updating   : libselinux-utils-2.5-6.el7.x86_64                                                                                                                                                                                       6/39   Updating   : policycoreutils-2.5-11.el7_3.x86_64                                                                                                                                                                                     7/39   Updating   : selinux-policy-3.13.1-102.el7_3.16.noarch                                                                                                                                                                               8/39   Installing : 2:docker-common-1.12.6-28.git1398f24.el7.centos.x86_64                                                                                                                                                                  9/39   Installing : 2:docker-client-1.12.6-28.git1398f24.el7.centos.x86_64                                                                                                                                                                 10/39   Updating   : selinux-policy-targeted-3.13.1-102.el7_3.16.noarch                                                                                                                                                                     11/39   Updating   : libsemanage-python-2.5-5.1.el7_3.x86_64                                                                                                                                                                                12/39   Installing : 1:oci-register-machine-0-3.11.gitdd0daef.el7.x86_64                                                                                                                                                                    13/39   Updating   : libselinux-python-2.5-6.el7.x86_64                                                                                                                                                                                     14/39   Installing : 1:oci-systemd-hook-0.1.7-2.git2788078.el7.x86_64                                                                                                                                                                       15/39   Updating   : setools-libs-3.3.8-1.1.el7.x86_64                                                                                                                                                                                      16/39   Updating   : policycoreutils-python-2.5-11.el7_3.x86_64                                                                                                                                                                             17/39   Installing : 2:container-selinux-2.12-2.gite7096ce.el7.noarch                                                                                                                                                                       18/39   Installing : 1:skopeo-containers-0.1.19-1.el7.x86_64                                                                                                                                                                                19/39 Stopping containers...Cannot connect to the Docker daemon. Is the docker daemon running on this host?"docker stop" requires at least 1 argument(s).See 'docker stop --help'.Usage:  docker stop [OPTIONS] CONTAINER [CONTAINER...]Stop one or more running containers  Installing : 2:docker-1.12.6-28.git1398f24.el7.centos.x86_64                                                                                                                                                                        20/39   Updating   : systemd-python-219-30.el7_3.9.x86_64                                                                                                                                                                                   21/39   Updating   : systemd-sysv-219-30.el7_3.9.x86_64                                                                                                                                                                                     22/39   Updating   : libgudev1-219-30.el7_3.9.x86_64                                                                                                                                                                                        23/39   Cleanup    : policycoreutils-python-2.2.5-20.el7.x86_64                                                                                                                                                                             24/39   Cleanup    : selinux-policy-targeted-3.13.1-60.el7.noarch                                                                                                                                                                           25/39   Cleanup    : systemd-python-219-19.el7.x86_64                                                                                                                                                                                       26/39   Cleanup    : selinux-policy-3.13.1-60.el7.noarch                                                                                                                                                                                    27/39   Cleanup    : systemd-sysv-219-19.el7.x86_64                                                                                                                                                                                         28/39   Cleanup    : policycoreutils-2.2.5-20.el7.x86_64                                                                                                                                                                                    29/39   Cleanup    : systemd-219-19.el7.x86_64                                                                                                                                                                                              30/39   Cleanup    : setools-libs-3.3.7-46.el7.x86_64                                                                                                                                                                                       31/39   Cleanup    : libselinux-utils-2.2.2-6.el7.x86_64                                                                                                                                                                                    32/39   Cleanup    : libselinux-python-2.2.2-6.el7.x86_64                                                                                                                                                                                   33/39   Cleanup    : libsemanage-python-2.1.10-18.el7.x86_64                                                                                                                                                                                34/39   Cleanup    : libsemanage-2.1.10-18.el7.x86_64                                                                                                                                                                                       35/39   Cleanup    : libgudev1-219-19.el7.x86_64                                                                                                                                                                                            36/39   Cleanup    : systemd-libs-219-19.el7.x86_64                                                                                                                                                                                         37/39   Cleanup    : libselinux-2.2.2-6.el7.x86_64                                                                                                                                                                                          38/39   Cleanup    : libsepol-2.1.9-3.el7.x86_64                                                                                                                                                                                            39/39   Verifying  : libsepol-2.5-6.el7.x86_64                                                                                                                                                                                               1/39   Verifying  : libselinux-python-2.5-6.el7.x86_64                                                                                                                                                                                      2/39   Verifying  : 1:oci-register-machine-0-3.11.gitdd0daef.el7.x86_64                                                                                                                                                                     3/39   Verifying  : policycoreutils-python-2.5-11.el7_3.x86_64                                                                                                                                                                              4/39   Verifying  : libselinux-utils-2.5-6.el7.x86_64                                                                                                                                                                                       5/39   Verifying  : policycoreutils-2.5-11.el7_3.x86_64                                                                                                                                                                                     6/39   Verifying  : 2:docker-1.12.6-28.git1398f24.el7.centos.x86_64                                                                                                                                                                         7/39   Verifying  : libgudev1-219-30.el7_3.9.x86_64                                                                                                                                                                                         8/39   Verifying  : systemd-219-30.el7_3.9.x86_64                                                                                                                                                                                           9/39   Verifying  : 2:docker-common-1.12.6-28.git1398f24.el7.centos.x86_64                                                                                                                                                                 10/39   Verifying  : selinux-policy-3.13.1-102.el7_3.16.noarch                                                                                                                                                                              11/39   Verifying  : selinux-policy-targeted-3.13.1-102.el7_3.16.noarch                                                                                                                                                                     12/39   Verifying  : libsemanage-2.5-5.1.el7_3.x86_64                                                                                                                                                                                       13/39   Verifying  : systemd-python-219-30.el7_3.9.x86_64                                                                                                                                                                                   14/39   Verifying  : 2:container-selinux-2.12-2.gite7096ce.el7.noarch                                                                                                                                                                       15/39   Verifying  : 1:skopeo-containers-0.1.19-1.el7.x86_64                                                                                                                                                                                16/39   Verifying  : libselinux-2.5-6.el7.x86_64                                                                                                                                                                                            17/39   Verifying  : systemd-sysv-219-30.el7_3.9.x86_64                                                                                                                                                                                     18/39   Verifying  : 1:oci-systemd-hook-0.1.7-2.git2788078.el7.x86_64                                                                                                                                                                       19/39   Verifying  : libsemanage-python-2.5-5.1.el7_3.x86_64                                                                                                                                                                                20/39   Verifying  : 2:docker-client-1.12.6-28.git1398f24.el7.centos.x86_64                                                                                                                                                                 21/39   Verifying  : systemd-libs-219-30.el7_3.9.x86_64                                                                                                                                                                                     22/39   Verifying  : setools-libs-3.3.8-1.1.el7.x86_64                                                                                                                                                                                      23/39   Verifying  : systemd-python-219-19.el7.x86_64                                                                                                                                                                                       24/39   Verifying  : libsemanage-python-2.1.10-18.el7.x86_64                                                                                                                                                                                25/39   Verifying  : setools-libs-3.3.7-46.el7.x86_64                                                                                                                                                                                       26/39   Verifying  : libsemanage-2.1.10-18.el7.x86_64                                                                                                                                                                                       27/39   Verifying  : systemd-sysv-219-19.el7.x86_64                                                                                                                                                                                         28/39   Verifying  : libgudev1-219-19.el7.x86_64                                                                                                                                                                                            29/39   Verifying  : systemd-219-19.el7.x86_64                                                                                                                                                                                              30/39   Verifying  : selinux-policy-3.13.1-60.el7.noarch                                                                                                                                                                                    31/39   Verifying  : systemd-libs-219-19.el7.x86_64                                                                                                                                                                                         32/39   Verifying  : libselinux-utils-2.2.2-6.el7.x86_64                                                                                                                                                                                    33/39   Verifying  : selinux-policy-targeted-3.13.1-60.el7.noarch                                                                                                                                                                           34/39   Verifying  : libsepol-2.1.9-3.el7.x86_64                                                                                                                                                                                            35/39   Verifying  : libselinux-python-2.2.2-6.el7.x86_64                                                                                                                                                                                   36/39   Verifying  : policycoreutils-2.2.5-20.el7.x86_64                                                                                                                                                                                    37/39   Verifying  : libselinux-2.2.2-6.el7.x86_64                                                                                                                                                                                          38/39   Verifying  : policycoreutils-python-2.2.5-20.el7.x86_64                                                                                                                                                                             39/39 Installed:  docker.x86_64 2:1.12.6-28.git1398f24.el7.centos                                                                                                                                                                                           Dependency Installed:  container-selinux.noarch 2:2.12-2.gite7096ce.el7       docker-client.x86_64 2:1.12.6-28.git1398f24.el7.centos       docker-common.x86_64 2:1.12.6-28.git1398f24.el7.centos       oci-register-machine.x86_64 1:0-3.11.gitdd0daef.el7        oci-systemd-hook.x86_64 1:0.1.7-2.git2788078.el7       skopeo-containers.x86_64 1:0.1.19-1.el7                     Updated:  selinux-policy-targeted.noarch 0:3.13.1-102.el7_3.16                                                                            systemd.x86_64 0:219-30.el7_3.9                                                                           Dependency Updated:  libgudev1.x86_64 0:219-30.el7_3.9              libselinux.x86_64 0:2.5-6.el7             libselinux-python.x86_64 0:2.5-6.el7        libselinux-utils.x86_64 0:2.5-6.el7               libsemanage.x86_64 0:2.5-5.1.el7_3                libsemanage-python.x86_64 0:2.5-5.1.el7_3      libsepol.x86_64 0:2.5-6.el7               policycoreutils.x86_64 0:2.5-11.el7_3       policycoreutils-python.x86_64 0:2.5-11.el7_3      selinux-policy.noarch 0:3.13.1-102.el7_3.16       setools-libs.x86_64 0:3.3.8-1.1.el7            systemd-libs.x86_64 0:219-30.el7_3.9      systemd-python.x86_64 0:219-30.el7_3.9      systemd-sysv.x86_64 0:219-30.el7_3.9             Complete![root@localhost ~]# 

2.启动docker


service docker start 
[root@localhost ~]# service docker startRedirecting to /bin/systemctl start  docker.service[root@localhost ~]# ps -ef|grep dockerroot      29129      1  0 11:25 ?        00:00:00 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --selinux-enabled --log-driver=journald --signature-verification=falseroot      29146  29129  0 11:25 ?        00:00:00 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --runtime docker-runc --runtime-args --systemd-cgroup=trueroot      29395   9865  0 11:27 pts/2    00:00:00 grep --color=auto docker[root@localhost ~]# 

3.加入开机启动

chkconfig docker on

从docker.io中下载centos镜像到本地 /var/lib/docker/graph

[root@localhost ~]# chkconfig docker on Note: Forwarding request to 'systemctl enable docker.service'.Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.[root@localhost ~]# 

4.查看已下载的镜像

docker images 
[root@localhost ~]# docker images REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE[root@localhost ~]# 

5.启动一个容器

docker run -i -t centos /bin/bash 
[root@localhost ~]# docker run -i -t centos /bin/bash Unable to find image 'centos:latest' locallyTrying to pull repository docker.io/library/centos ... latest: Pulling from docker.io/library/centosd5e46245fe40: Downloading [==>                                                ] 3.244 MB/70.49 MB^C[root@localhost ~]# 

6.查看所有容器

docker ps -a 
[root@localhost ~]# docker ps -aCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES[root@localhost ~]# 

7.开启一个容器

docker start container 

8.查看容器的root用户密码

docker logs <容器ID或者容器名> 2>&1 | grep '^User:' | tail -n1 

9.查看容器日志

docker logs -s <容器ID或者容器名> 

10.删除单个容器docker容器

docker rm loving_ride 

11.删除所有容器

docker rm $(docker ps -a -q) 

12.停止容docker stop 容器

docker start 

13.运行一个新容器,同时为它命名、端口映射、文件夹映射。以redmine镜像为例

docker run --name redmine -p 9003:80 -p 9023:22 -d -v /var/redmine/files:/redmine/files -v/var/redmine/mysql:/var/lib/mysql sameersbn/redmine 

14. 一个容器连接到另一个容器&sonar容器连接到mmysql容器,并将mmysql容器重命名为db。这样,sonar容器就可以使用db的相关的环境变量了。

run -i -t --name sonar -d -link mmysql:dbtpires/sonar-server 

15. 当需要把一台机器上的镜像迁移到另一台机器的时候,需要保存镜像与加载镜像

docker save > /home/aa.tar 

16.拷贝文件到另一机器

scp -r /home/aa.tar root@192.168.1.65:/home/aa.tar 

17.加载打包好的镜像

docker load < /home/aa.tar 

18.构建自己的镜像

docker build -t <镜像名> <镜像文件路径>

eg:docker build -t aa /home/aa.tar