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

本文涉及的产品
容器镜像服务 ACR,镜像仓库100个 不限时长
简介: 安装部署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
目录
相关文章
|
3天前
|
Kubernetes Linux 开发者
深入探索容器化技术——Docker 的实战应用
深入探索容器化技术——Docker 的实战应用
25 5
|
7天前
|
运维 Cloud Native 云计算
云原生之旅:Docker容器化实战
本文将带你走进云原生的世界,深入理解Docker技术如何改变应用部署与运维。我们将通过实际案例,展示如何利用Docker简化开发流程,提升应用的可移植性和伸缩性。文章不仅介绍基础概念,还提供操作指南和最佳实践,帮助你快速上手Docker,开启云原生的第一步。
|
2天前
|
持续交付 开发者 Docker
探索容器化技术Docker及其在现代软件开发中的应用
探索容器化技术Docker及其在现代软件开发中的应用
|
5天前
|
关系型数据库 MySQL Java
【Docker最新版教程】一文带你快速入门Docker常见用法,实现容器编排和自动化部署上线项目
Docker快速入门到项目部署,MySQL部署+Nginx部署+docker自定义镜像+docker网络+DockerCompose项目实战一文搞定!
|
4天前
|
开发者 Docker Python
从零开始:使用Docker容器化你的Python Web应用
从零开始:使用Docker容器化你的Python Web应用
15 1
|
7天前
|
运维 Kubernetes Cloud Native
云原生技术入门:Kubernetes和Docker的协同工作
【10月更文挑战第43天】在云计算时代,云原生技术成为推动现代软件部署和运行的关键力量。本篇文章将带你了解云原生的基本概念,重点探讨Kubernetes和Docker如何协同工作以支持容器化应用的生命周期管理。通过实际代码示例,我们将展示如何在Kubernetes集群中部署和管理Docker容器,从而为初学者提供一条清晰的学习路径。
|
10天前
|
机器学习/深度学习 数据采集 Docker
Docker容器化实战:构建并部署一个简单的Web应用
Docker容器化实战:构建并部署一个简单的Web应用
|
8天前
|
运维 持续交付 虚拟化
深入解析Docker容器化技术的核心原理
深入解析Docker容器化技术的核心原理
28 1
|
10天前
|
JavaScript 开发者 Docker
Docker容器化实战:构建并部署一个简单的Web应用
Docker容器化实战:构建并部署一个简单的Web应用
|
1天前
|
存储 Cloud Native 开发者
深入探索容器化技术——Docker的实战应用
深入探索容器化技术——Docker的实战应用
7 0
下一篇
无影云桌面