零基础容器技术实战--docker安装

本文涉及的产品
容器镜像服务 ACR,镜像仓库100个 不限时长
容器服务 Serverless 版 ACK Serverless,952元额度 多规格
容器服务 Serverless 版 ACK Serverless,317元额度 多规格
简介: 安装部署docker
Last login: Mon Feb 2110:28:00 2022 from 47.96.60.211
Welcome to Alibaba Cloud Elastic Compute Service !
1、安装前置依赖环境
[root@iZuf6ixbmgow7oayuoyxeyZ ~]# yum install -y yum-utils device-mapper-persistent-data lvm2Loaded plugins: fastestmirror
Determining fastest mirrors
base                                                                                                                                            | 3.6 kB  00:00:00     
epel                                                                                                                                            | 4.7 kB  00:00:00     
extras                                                                                                                                          | 2.9 kB  00:00:00     
updates                                                                                                                                         | 2.9 kB  00:00:00     
(1/7): base/7/x86_64/group_gz                                                                                                                   | 153 kB  00:00:00     
(2/7): epel/x86_64/group_gz                                                                                                                     |  96 kB  00:00:00     
(3/7): epel/x86_64/updateinfo                                                                                                                   | 1.0 MB  00:00:00     
(4/7): extras/7/x86_64/primary_db                                                                                                               | 243 kB  00:00:00     
(5/7): base/7/x86_64/primary_db                                                                                                                 | 6.1 MB  00:00:00     
(6/7): epel/x86_64/primary_db                                                                                                                   | 7.0 MB  00:00:00     
(7/7): updates/7/x86_64/primary_db                                                                                                              |  13 MB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package device-mapper-persistent-data.x86_64 0:0.8.5-3.el7_9.2 will be installed
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64
---> Package lvm2.x86_64 7:2.02.187-6.el7_9.5 will be installed
--> Processing Dependency: lvm2-libs =7:2.02.187-6.el7_9.5 for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64
--> Processing Dependency: liblvm2app.so.2.2(Base)(64bit) for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64
--> Processing Dependency: libdevmapper-event.so.1.02(Base)(64bit) for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64
--> Processing Dependency: liblvm2app.so.2.2()(64bit) for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64
--> Processing Dependency: libdevmapper-event.so.1.02()(64bit) for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64
---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be installed
--> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-54.el7_8.noarch
--> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-54.el7_8.noarch
--> Running transaction check
---> Package device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5 will be installed
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package libxml2-python.x86_64 0:2.9.1-6.el7_9.6 will be installed
--> Processing Dependency: libxml2 =2.9.1-6.el7_9.6 for package: libxml2-python-2.9.1-6.el7_9.6.x86_64
---> Package lvm2-libs.x86_64 7:2.02.187-6.el7_9.5 will be installed
--> Processing Dependency: device-mapper-event =7:1.02.170-6.el7_9.5 for package: 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64
---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
--> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch
--> Running transaction check
---> Package device-mapper-event.x86_64 7:1.02.170-6.el7_9.5 will be installed
--> Processing Dependency: device-mapper =7:1.02.170-6.el7_9.5 for package: 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64
---> Package libxml2.x86_64 0:2.9.1-6.el7_2.3 will be updated
---> Package libxml2.x86_64 0:2.9.1-6.el7_9.6 will be an update
---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed
--> Running transaction check
---> Package device-mapper.x86_64 7:1.02.158-2.el7_7.2 will be updated
--> Processing Dependency: device-mapper =7:1.02.158-2.el7_7.2 for package: 7:device-mapper-libs-1.02.158-2.el7_7.2.x86_64
---> Package device-mapper.x86_64 7:1.02.170-6.el7_9.5 will be an update
--> Running transaction check
---> Package device-mapper-libs.x86_64 7:1.02.158-2.el7_7.2 will be updated
---> Package device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================================================= Package                                              Arch                          Version                                       Repository                      Size
=======================================================================================================================================================================Installing:
 device-mapper-persistent-data                        x86_64                        0.8.5-3.el7_9.2                               updates                        423 k
 lvm2                                                 x86_64                        7:2.02.187-6.el7_9.5                          updates                        1.3 M
 yum-utils                                            noarch                        1.1.31-54.el7_8                               base                           122 k
Installing for dependencies:
 device-mapper-event                                  x86_64                        7:1.02.170-6.el7_9.5                          updates                        192 k
 device-mapper-event-libs                             x86_64                        7:1.02.170-6.el7_9.5                          updates                        192 k
 libaio                                               x86_64                        0.3.109-13.el7                                base                            24 k
 libxml2-python                                       x86_64                        2.9.1-6.el7_9.6                               updates                        247 k
 lvm2-libs                                            x86_64                        7:2.02.187-6.el7_9.5                          updates                        1.1 M
 python-chardet                                       noarch                        2.2.1-3.el7                                   base                           227 k
 python-kitchen                                       noarch                        1.1.1-5.el7                                   base                           267 k
Updating for dependencies:
 device-mapper                                        x86_64                        7:1.02.170-6.el7_9.5                          updates                        297 k
 device-mapper-libs                                   x86_64                        7:1.02.170-6.el7_9.5                          updates                        325 k
 libxml2                                              x86_64                        2.9.1-6.el7_9.6                               updates                        668 k
Transaction Summary
=======================================================================================================================================================================Install  3 Packages (+7 Dependent packages)
Upgrade             ( 3 Dependent packages)
Total download size: 5.3 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/13): device-mapper-event-1.02.170-6.el7_9.5.x86_64.rpm                                                                                       | 192 kB  00:00:00     
(2/13): device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64.rpm                                                                                  | 192 kB  00:00:00     
(3/13): device-mapper-1.02.170-6.el7_9.5.x86_64.rpm                                                                                             | 297 kB  00:00:00     
(4/13): device-mapper-libs-1.02.170-6.el7_9.5.x86_64.rpm                                                                                        | 325 kB  00:00:00     
(5/13): device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64.rpm                                                                                | 423 kB  00:00:00     
(6/13): libaio-0.3.109-13.el7.x86_64.rpm                                                                                                        |  24 kB  00:00:00     
(7/13): libxml2-2.9.1-6.el7_9.6.x86_64.rpm                                                                                                      | 668 kB  00:00:00     
(8/13): libxml2-python-2.9.1-6.el7_9.6.x86_64.rpm                                                                                               | 247 kB  00:00:00     
(9/13): lvm2-libs-2.02.187-6.el7_9.5.x86_64.rpm                                                                                                 | 1.1 MB  00:00:00     
(10/13): python-chardet-2.2.1-3.el7.noarch.rpm                                                                                                  | 227 kB  00:00:00     
(11/13): lvm2-2.02.187-6.el7_9.5.x86_64.rpm                                                                                                     | 1.3 MB  00:00:00     
(12/13): yum-utils-1.1.31-54.el7_8.noarch.rpm                                                                                                   | 122 kB  00:00:00     
(13/13): python-kitchen-1.1.1-5.el7.noarch.rpm                                                                                                  | 267 kB  00:00:00     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------Total                                                                                                                                   12 MB/s | 5.3 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libaio-0.3.109-13.el7.x86_64                                                                                                                       1/16 
  Updating   : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64                                                                                                     2/16 
  Updating   : 7:device-mapper-1.02.170-6.el7_9.5.x86_64                                                                                                          3/16 
  Installing : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64                                                                                               4/16 
  Installing : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64                                                                                                    5/16 
  Installing : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64                                                                                                              6/16 
  Installing : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64                                                                                               7/16 
  Updating   : libxml2-2.9.1-6.el7_9.6.x86_64                                                                                                                     8/16 
  Installing : libxml2-python-2.9.1-6.el7_9.6.x86_64                                                                                                              9/16 
  Installing : python-chardet-2.2.1-3.el7.noarch                                                                                                                 10/16 
  Installing : python-kitchen-1.1.1-5.el7.noarch                                                                                                                 11/16 
  Installing : yum-utils-1.1.31-54.el7_8.noarch                                                                                                                  12/16 
  Installing : 7:lvm2-2.02.187-6.el7_9.5.x86_64                                                                                                                  13/16 
  Cleanup    : 7:device-mapper-libs-1.02.158-2.el7_7.2.x86_64                                                                                                    14/16 
  Cleanup    : 7:device-mapper-1.02.158-2.el7_7.2.x86_64                                                                                                         15/16 
  Cleanup    : libxml2-2.9.1-6.el7_2.3.x86_64                                                                                                                    16/16 
  Verifying  : 7:lvm2-2.02.187-6.el7_9.5.x86_64                                                                                                                   1/16 
  Verifying  : python-chardet-2.2.1-3.el7.noarch                                                                                                                  2/16 
  Verifying  : libxml2-2.9.1-6.el7_9.6.x86_64                                                                                                                     3/16 
  Verifying  : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64                                                                                                              4/16 
  Verifying  : libxml2-python-2.9.1-6.el7_9.6.x86_64                                                                                                              5/16 
  Verifying  : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64                                                                                               6/16 
  Verifying  : 7:device-mapper-1.02.170-6.el7_9.5.x86_64                                                                                                          7/16 
  Verifying  : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64                                                                                                    8/16 
  Verifying  : python-kitchen-1.1.1-5.el7.noarch                                                                                                                  9/16 
  Verifying  : libaio-0.3.109-13.el7.x86_64                                                                                                                      10/16 
  Verifying  : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64                                                                                              11/16 
  Verifying  : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64                                                                                                    12/16 
  Verifying  : yum-utils-1.1.31-54.el7_8.noarch                                                                                                                  13/16 
  Verifying  : libxml2-2.9.1-6.el7_2.3.x86_64                                                                                                                    14/16 
  Verifying  : 7:device-mapper-libs-1.02.158-2.el7_7.2.x86_64                                                                                                    15/16 
  Verifying  : 7:device-mapper-1.02.158-2.el7_7.2.x86_64                                                                                                         16/16 
Installed:
  device-mapper-persistent-data.x86_64 0:0.8.5-3.el7_9.2               lvm2.x86_64 7:2.02.187-6.el7_9.5               yum-utils.noarch 0:1.1.31-54.el7_8              
Dependency Installed:
  device-mapper-event.x86_64 7:1.02.170-6.el7_9.5          device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5          libaio.x86_64 0:0.3.109-13.el7              
  libxml2-python.x86_64 0:2.9.1-6.el7_9.6                  lvm2-libs.x86_64 7:2.02.187-6.el7_9.5                         python-chardet.noarch 0:2.2.1-3.el7         
  python-kitchen.noarch 0:1.1.1-5.el7                     
Dependency Updated:
  device-mapper.x86_64 7:1.02.170-6.el7_9.5               device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5               libxml2.x86_64 0:2.9.1-6.el7_9.6              
Complete!
2、配置repo
[root@iZuf6ixbmgow7oayuoyxeyZ ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repoLoaded plugins: fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
3、安装docker
[root@iZuf6ixbmgow7oayuoyxeyZ ~]# yum makecache fast &&> yum -y install docker-ce
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base                                                                                                                                            | 3.6 kB  00:00:00     
docker-ce-stable                                                                                                                                | 3.5 kB  00:00:00     
epel                                                                                                                                            | 4.7 kB  00:00:00     
extras                                                                                                                                          | 2.9 kB  00:00:00     
updates                                                                                                                                         | 2.9 kB  00:00:00     
(1/2): docker-ce-stable/7/x86_64/updateinfo                                                                                                     |   55 B  00:00:00     
(2/2): docker-ce-stable/7/x86_64/primary_db                                                                                                     |  70 kB  00:00:00     
Metadata Cache Created
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:20.10.12-3.el7 will be installed
--> Processing Dependency: container-selinux >=2:2.74 for package: 3:docker-ce-20.10.12-3.el7.x86_64
--> Processing Dependency: containerd.io >=1.4.1 for package: 3:docker-ce-20.10.12-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-20.10.12-3.el7.x86_64
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.12-3.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-20.10.12-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
---> Package containerd.io.x86_64 0:1.4.12-3.1.el7 will be installed
---> Package docker-ce-cli.x86_64 1:20.10.12-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.12-3.el7.x86_64
---> Package docker-ce-rootless-extras.x86_64 0:20.10.12-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >=0.7 for package: docker-ce-rootless-extras-20.10.12-3.el7.x86_64
--> Processing Dependency: slirp4netns >=0.4 for package: docker-ce-rootless-extras-20.10.12-3.el7.x86_64
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
--> Running transaction check
---> Package docker-scan-plugin.x86_64 0:0.12.0-3.el7 will be installed
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
--> Processing Dependency: policycoreutils =2.5-34.el7 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: setools-libs >=3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libsemanage-python >=2.5-14 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: audit-libs-python >=2.1.3-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package policycoreutils.x86_64 0:2.5-33.el7 will be updated
---> Package policycoreutils.x86_64 0:2.5-34.el7 will be an update
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================================================= Package                                        Arch                        Version                                        Repository                             Size
=======================================================================================================================================================================Installing:
 docker-ce                                      x86_64                      3:20.10.12-3.el7                               docker-ce-stable                       23 M
Installing for dependencies:
 audit-libs-python                              x86_64                      2.8.5-4.el7                                    base                                   76 k
 checkpolicy                                    x86_64                      2.5-8.el7                                      base                                  295 k
 container-selinux                              noarch                      2:2.119.2-1.911c772.el7_8                      extras                                 40 k
 containerd.io                                  x86_64                      1.4.12-3.1.el7                                 docker-ce-stable                       28 M
 docker-ce-cli                                  x86_64                      1:20.10.12-3.el7                               docker-ce-stable                       30 M
 docker-ce-rootless-extras                      x86_64                      20.10.12-3.el7                                 docker-ce-stable                      8.0 M
 docker-scan-plugin                             x86_64                      0.12.0-3.el7                                   docker-ce-stable                      3.7 M
 fuse-overlayfs                                 x86_64                      0.7.2-6.el7_8                                  extras                                 54 k
 fuse3-libs                                     x86_64                      3.6.1-4.el7                                    extras                                 82 k
 libcgroup                                      x86_64                      0.41-21.el7                                    base                                   66 k
 libsemanage-python                             x86_64                      2.5-14.el7                                     base                                  113 k
 policycoreutils-python                         x86_64                      2.5-34.el7                                     base                                  457 k
 python-IPy                                     noarch                      0.75-6.el7                                     base                                   32 k
 setools-libs                                   x86_64                      3.3.8-4.el7                                    base                                  620 k
 slirp4netns                                    x86_64                      0.4.3-4.el7_8                                  extras                                 81 k
Updating for dependencies:
 policycoreutils                                x86_64                      2.5-34.el7                                     base                                  917 k
Transaction Summary
=======================================================================================================================================================================Install  1 Package  (+15 Dependent packages)
Upgrade             (  1 Dependent package)
Total download size: 96 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/17): audit-libs-python-2.8.5-4.el7.x86_64.rpm                                                                                                |  76 kB  00:00:00     
(2/17): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm                                                                                    |  40 kB  00:00:00     
(3/17): checkpolicy-2.5-8.el7.x86_64.rpm                                                                                                        | 295 kB  00:00:00     
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-20.10.12-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEYMB  00:00:09 ETA 
Public key for docker-ce-20.10.12-3.el7.x86_64.rpm is not installed
(4/17): docker-ce-20.10.12-3.el7.x86_64.rpm                                                                                                     |  23 MB  00:00:06     
(5/17): containerd.io-1.4.12-3.1.el7.x86_64.rpm                                                                                                 |  28 MB  00:00:08     
(6/17): docker-ce-rootless-extras-20.10.12-3.el7.x86_64.rpm                                                                                     | 8.0 MB  00:00:02     
(7/17): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm                                                                                                 |  54 kB  00:00:00     
(8/17): libsemanage-python-2.5-14.el7.x86_64.rpm                                                                                                | 113 kB  00:00:00     
(9/17): policycoreutils-2.5-34.el7.x86_64.rpm                                                                                                   | 917 kB  00:00:00     
(10/17): policycoreutils-python-2.5-34.el7.x86_64.rpm                                                                                           | 457 kB  00:00:00     
(11/17): libcgroup-0.41-21.el7.x86_64.rpm                                                                                                       |  66 kB  00:00:00     
(12/17): fuse3-libs-3.6.1-4.el7.x86_64.rpm                                                                                                      |  82 kB  00:00:00     
(13/17): python-IPy-0.75-6.el7.noarch.rpm                                                                                                       |  32 kB  00:00:00     
(14/17): setools-libs-3.3.8-4.el7.x86_64.rpm                                                                                                    | 620 kB  00:00:00     
(15/17): slirp4netns-0.4.3-4.el7_8.x86_64.rpm                                                                                                   |  81 kB  00:00:00     
(16/17): docker-scan-plugin-0.12.0-3.el7.x86_64.rpm                                                                                             | 3.7 MB  00:00:01     
(17/17): docker-ce-cli-20.10.12-3.el7.x86_64.rpm                                                                                                |  30 MB  00:00:08     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------Total                                                                                                                                  6.2 MB/s |  96 MB  00:00:15     
Retrieving key from https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>" Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 From       : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
   Installing : docker-scan-plugin-0.12.0-3.el7.x86_64                                                                                                             1/18 
  Installing : 1:docker-ce-cli-20.10.12-3.el7.x86_64                                                                                                              2/18 
  Installing : libcgroup-0.41-21.el7.x86_64                                                                                                                       3/18 
  Updating   : policycoreutils-2.5-34.el7.x86_64                                                                                                                  4/18 
  Installing : setools-libs-3.3.8-4.el7.x86_64                                                                                                                    5/18 
  Installing : python-IPy-0.75-6.el7.noarch                                                                                                                       6/18 
  Installing : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                                                   7/18 
  Installing : libsemanage-python-2.5-14.el7.x86_64                                                                                                               8/18 
  Installing : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                               9/18 
  Installing : fuse3-libs-3.6.1-4.el7.x86_64                                                                                                                     10/18 
  Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                                                               11/18 
  Installing : checkpolicy-2.5-8.el7.x86_64                                                                                                                      12/18 
  Installing : policycoreutils-python-2.5-34.el7.x86_64                                                                                                          13/18 
  Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                                14/18 
setsebool:  SELinux is disabled.
  Installing : containerd.io-1.4.12-3.1.el7.x86_64                                                                                                               15/18 
  Installing : docker-ce-rootless-extras-20.10.12-3.el7.x86_64                                                                                                   16/18 
  Installing : 3:docker-ce-20.10.12-3.el7.x86_64                                                                                                                 17/18 
  Cleanup    : policycoreutils-2.5-33.el7.x86_64                                                                                                                 18/18 
  Verifying  : checkpolicy-2.5-8.el7.x86_64                                                                                                                       1/18 
  Verifying  : fuse3-libs-3.6.1-4.el7.x86_64                                                                                                                      2/18 
  Verifying  : 1:docker-ce-cli-20.10.12-3.el7.x86_64                                                                                                              3/18 
  Verifying  : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                               4/18 
  Verifying  : policycoreutils-2.5-34.el7.x86_64                                                                                                                  5/18 
  Verifying  : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                                                                6/18 
  Verifying  : libsemanage-python-2.5-14.el7.x86_64                                                                                                               7/18 
  Verifying  : docker-scan-plugin-0.12.0-3.el7.x86_64                                                                                                             8/18 
  Verifying  : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                                                   9/18 
  Verifying  : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                                10/18 
  Verifying  : python-IPy-0.75-6.el7.noarch                                                                                                                      11/18 
  Verifying  : policycoreutils-python-2.5-34.el7.x86_64                                                                                                          12/18 
  Verifying  : docker-ce-rootless-extras-20.10.12-3.el7.x86_64                                                                                                   13/18 
  Verifying  : containerd.io-1.4.12-3.1.el7.x86_64                                                                                                               14/18 
  Verifying  : setools-libs-3.3.8-4.el7.x86_64                                                                                                                   15/18 
  Verifying  : 3:docker-ce-20.10.12-3.el7.x86_64                                                                                                                 16/18 
  Verifying  : libcgroup-0.41-21.el7.x86_64                                                                                                                      17/18 
  Verifying  : policycoreutils-2.5-33.el7.x86_64                                                                                                                 18/18 
Installed:
  docker-ce.x86_64 3:20.10.12-3.el7                                                                                                                                    
Dependency Installed:
  audit-libs-python.x86_64 0:2.8.5-4.el7              checkpolicy.x86_64 0:2.5-8.el7                    container-selinux.noarch 2:2.119.2-1.911c772.el7_8           
  containerd.io.x86_64 0:1.4.12-3.1.el7               docker-ce-cli.x86_64 1:20.10.12-3.el7             docker-ce-rootless-extras.x86_64 0:20.10.12-3.el7            
  docker-scan-plugin.x86_64 0:0.12.0-3.el7            fuse-overlayfs.x86_64 0:0.7.2-6.el7_8             fuse3-libs.x86_64 0:3.6.1-4.el7                              
  libcgroup.x86_64 0:0.41-21.el7                      libsemanage-python.x86_64 0:2.5-14.el7            policycoreutils-python.x86_64 0:2.5-34.el7                   
  python-IPy.noarch 0:0.75-6.el7                      setools-libs.x86_64 0:3.3.8-4.el7                 slirp4netns.x86_64 0:0.4.3-4.el7_8                           
Dependency Updated:
  policycoreutils.x86_64 0:2.5-34.el7                                                                                                                                  
Complete!
4、启动docker服务
[root@iZuf6ixbmgow7oayuoyxeyZ ~]# systemctl start docker[root@iZuf6ixbmgow7oayuoyxeyZ ~]# tee /etc/docker/daemon.json <<-'EOF'> {
>   "registry-mirrors": ["https://registry.docker-cn.com"]
> }
> EOF
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
[root@iZuf6ixbmgow7oayuoyxeyZ ~]# systemctl start docker[root@iZuf6ixbmgow7oayuoyxeyZ ~]# tee /etc/docker/daemon.json <<-'EOF'> {
>   "registry-mirrors": ["https://registry.docker-cn.com"]
> }
> EOF
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
[root@iZuf6ixbmgow7oayuoyxeyZ ~]# systemctl restart docker[root@iZuf6ixbmgow7oayuoyxeyZ ~]# mkdir -p /tmp/demo && cd /tmp/demo[root@iZuf6ixbmgow7oayuoyxeyZ demo]# cat > /tmp/demo/main.go << EOF> package main
> 
> import (
>         "fmt">         "net/http"> )
> 
> func main() {
>         http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
>                 fmt.Fprintf(w, "Hello! World\n")
>         })
> 
>         fmt.Println("start to serve...")
>         http.ListenAndServe(":80", nil)
> }
> EOF
[root@iZuf6ixbmgow7oayuoyxeyZ demo]# cat > /tmp/demo/Dockerfile << EOF> FROM golang:1.12-alpine
> 
> # change current working dir> WORKDIR /go/src/app
> 
> # copy main.go into /go/src/app> COPY . .
> 
> # go build and install the app> RUN go install -v ./...
> 
> # run the app by default> CMD ["app"]
> EOF
5、创建demo:v1
[root@iZuf6ixbmgow7oayuoyxeyZ demo]# docker build . -t demo:v1Sending build context to Docker daemon  3.072kB
Step 1/5 : FROM golang:1.12-alpine
1.12-alpine: Pulling from library/golang
c9b1b535fdd9: Pull complete 
cbb0d8da1b30: Pull complete 
d909eff28200: Pull complete 
665fbbf998e4: Pull complete 
4985b1919860: Pull complete 
Digest: sha256:3f8e3ad3e7c128d29ac3004ac8314967c5ddbfa5bfa7caa59b0de493fc01686a
Status: Downloaded newer image for golang:1.12-alpine
---> 76bddfb5e55e
Step 2/5 : WORKDIR /go/src/app
---> Running in cbfe71501511
Removing intermediate container cbfe71501511
---> 6fb6ecd73293
Step 3/5 : COPY . .
---> 98069bb983fe
Step 4/5 : RUN go install -v ./...
---> Running in 08a484780233
app
Removing intermediate container 08a484780233
---> 97bb0c70a9cd
Step 5/5 : CMD ["app"]
---> Running in a6891fc39167
Removing intermediate container a6891fc39167
---> 76b64c450d6c
Successfully built 76b64c450d6c
Successfully tagged demo:v1
[root@iZuf6ixbmgow7oayuoyxeyZ demo]# docker run -d -p 8000:80 demo:v19ff32b8874001ba7bc470c42eb6ea8194abca89fbdf1c703072e7cb92c8ab87e
[root@iZuf6ixbmgow7oayuoyxeyZ demo]# curl localhost:8000Hello! World
6、删除镜像
[root@iZuf6ixbmgow7oayuoyxeyZ demo]# docker rm -f $(docker ps -a | grep "demo:v1" | awk '{print $1}')9ff32b887400
目录
相关文章
|
1天前
|
SQL 关系型数据库 数据库
国产数据实战之docker部署MyWebSQL数据库管理工具
【10月更文挑战第23天】国产数据实战之docker部署MyWebSQL数据库管理工具
12 2
国产数据实战之docker部署MyWebSQL数据库管理工具
|
1天前
|
Prometheus 监控 Cloud Native
基于Docker安装Grafana和Prometheus
Grafana 是一款用 Go 语言开发的开源数据可视化工具,支持数据监控和统计,并具备告警功能。通过 Docker 部署 Grafana 和 Prometheus,可实现系统数据的采集、展示和告警。默认登录用户名和密码均为 admin。配置 Prometheus 数据源后,可导入主机监控模板(ID 8919)进行数据展示。
17 2
|
5天前
|
Web App开发 iOS开发 Docker
Docker 容器的日志
【10月更文挑战第31天】
16 5
|
3天前
|
消息中间件 Linux RocketMQ
在Red Hat Enterprise Linux 9上使用Docker快速安装并部署
通过以上步骤,你可以在Red Hat Enterprise Linux 9上使用Docker快速安装并部署RocketMQ。这种方法不仅简化了安装过程,还提供了一个灵活的环境来管理和扩展消息队列系统。RocketMQ作为一款高性能的分布式消息系统,通过Docker可以实现快速部署和高效管理。
13 2
|
4天前
|
存储 Kubernetes C++
Kubernetes VS Docker Swarm:哪个容器编排工具更适合你?
随着容器技术的快速发展,容器编排工具成为了现代软件开发和运维的重要环节。在众多容器编排工具中,Kubernetes和Docker Swarm无疑是最受欢迎的两个。本文将从技术特性、易用性和社区支持三个方面,对Kubernetes和Docker Swarm进行比较,以帮助您选择更适合您需求的容器编排工具。
19 3
|
4天前
|
消息中间件 Linux RocketMQ
在Red Hat Enterprise Linux 9上使用Docker快速安装并部署
通过以上步骤,你可以在Red Hat Enterprise Linux 9上使用Docker快速安装并部署RocketMQ。这种方法不仅简化了安装过程,还提供了一个灵活的环境来管理和扩展消息队列系统。RocketMQ作为一款高性能的分布式消息系统,通过Docker可以实现快速部署和高效管理。
12 3
|
1天前
|
存储 持续交付 虚拟化
|
5天前
|
存储 缓存 Docker
docker中挂载数据卷到容器
【10月更文挑战第16天】
15 2
|
7天前
|
关系型数据库 MySQL Linux
基于阿里云服务器Linux系统安装Docker完整图文教程(附部署开源项目)
基于阿里云服务器Linux系统安装Docker完整图文教程(附部署开源项目)
81 2
|
7天前
|
JavaScript 前端开发 Docker
前端的全栈之路Meteor篇(一):开发环境的搭建 -全局安装或使用容器镜像
本文介绍了如何搭建 Meteor 开发环境,包括全局安装 Meteor 工具和使用 Docker 镜像两种方法,以及创建和运行一个简单的 Meteor 项目的基本步骤。 Meteor 是一个全栈 JavaScript 框架,适用于构建实时 Web 应用程序。文章还提供了遇到问题时的解决建议和调试技巧。

热门文章

最新文章