零基础容器技术实战--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
目录
相关文章
|
6天前
|
弹性计算 Ubuntu Linux
阿里云服务器一键安装Docker社区版教程,基于系统运维管理OOS
阿里云服务器一键安装Docker社区版教程,基于系统运维管理OOS自动化部署。支持Ubuntu 22.04/20.04、CentOS 7.7-7.9及Alibaba Cloud Linux 3.2104 LTS。前提条件:ECS实例需运行中且有公网。步骤:选择Docker扩展并安装,验证成功通过命令`docker -v`查看版本号。
145 78
|
20天前
|
NoSQL 关系型数据库 应用服务中间件
docker基础篇:安装tomcat
docker基础篇:安装tomcat
156 64
|
11天前
|
Ubuntu Linux 开发工具
docker 是什么?docker初认识之如何部署docker-优雅草后续将会把产品发布部署至docker容器中-因此会出相关系列文章-优雅草央千澈
Docker 是一个开源的容器化平台,允许开发者将应用程序及其依赖项打包成标准化单元(容器),确保在任何支持 Docker 的操作系统上一致运行。容器共享主机内核,提供轻量级、高效的执行环境。本文介绍如何在 Ubuntu 上安装 Docker,并通过简单步骤验证安装成功。后续文章将探讨使用 Docker 部署开源项目。优雅草央千澈 源、安装 Docker 包、验证安装 - 适用场景:开发、测试、生产环境 通过以上步骤,您可以在 Ubuntu 系统上成功安装并运行 Docker,为后续的应用部署打下基础。
docker 是什么?docker初认识之如何部署docker-优雅草后续将会把产品发布部署至docker容器中-因此会出相关系列文章-优雅草央千澈
|
17天前
|
存储 Kubernetes 开发者
容器化时代的领航者:Docker 和 Kubernetes 云原生时代的黄金搭档
Docker 是一种开源的应用容器引擎,允许开发者将应用程序及其依赖打包成可移植的镜像,并在任何支持 Docker 的平台上运行。其核心概念包括镜像、容器和仓库。镜像是只读的文件系统,容器是镜像的运行实例,仓库用于存储和分发镜像。Kubernetes(k8s)则是容器集群管理系统,提供自动化部署、扩展和维护等功能,支持服务发现、负载均衡、自动伸缩等特性。两者结合使用,可以实现高效的容器化应用管理和运维。Docker 主要用于单主机上的容器管理,而 Kubernetes 则专注于跨多主机的容器编排与调度。尽管 k8s 逐渐减少了对 Docker 作为容器运行时的支持,但 Doc
90 5
容器化时代的领航者:Docker 和 Kubernetes 云原生时代的黄金搭档
|
1天前
|
Kubernetes Linux 虚拟化
入门级容器技术解析:Docker和K8s的区别与关系
本文介绍了容器技术的发展历程及其重要组成部分Docker和Kubernetes。从传统物理机到虚拟机,再到容器化,每一步都旨在更高效地利用服务器资源并简化应用部署。容器技术通过隔离环境、减少依赖冲突和提高可移植性,解决了传统部署方式中的诸多问题。Docker作为容器化平台,专注于创建和管理容器;而Kubernetes则是一个强大的容器编排系统,用于自动化部署、扩展和管理容器化应用。两者相辅相成,共同推动了现代云原生应用的快速发展。
24 10
|
10天前
|
NoSQL 关系型数据库 Redis
《docker高级篇(大厂进阶):1.Docker复杂安装详说》包括:安装mysql主从复制、安装redis集群
《docker高级篇(大厂进阶):1.Docker复杂安装详说》包括:安装mysql主从复制、安装redis集群
54 14
|
1天前
|
Ubuntu NoSQL Linux
《docker基础篇:3.Docker常用命令》包括帮助启动类命令、镜像命令、有镜像才能创建容器,这是根本前提(下载一个CentOS或者ubuntu镜像演示)、容器命令、小总结
《docker基础篇:3.Docker常用命令》包括帮助启动类命令、镜像命令、有镜像才能创建容器,这是根本前提(下载一个CentOS或者ubuntu镜像演示)、容器命令、小总结
19 6
《docker基础篇:3.Docker常用命令》包括帮助启动类命令、镜像命令、有镜像才能创建容器,这是根本前提(下载一个CentOS或者ubuntu镜像演示)、容器命令、小总结
|
7天前
|
关系型数据库 MySQL 应用服务中间件
《docker基础篇:8.Docker常规安装简介》包括:docker常规安装总体步骤、安装tomcat、安装mysql、安装redis
《docker基础篇:8.Docker常规安装简介》包括:docker常规安装总体步骤、安装tomcat、安装mysql、安装redis
43 7
|
21天前
|
Ubuntu Linux Docker
Ubuntu22.04上Docker的安装
通过以上详细的安装步骤和命令,您可以在Ubuntu 22.04系统上顺利安装
342 11
|
17天前
|
Unix Linux Docker
CentOS停更沉寂,RHEL巨变限制源代:Docker容器化技术的兴起助力操作系统新格局
操作系统是计算机系统的核心软件,管理和控制硬件与软件资源,为用户和应用程序提供高效、安全的运行环境。Linux作为开源、跨平台的操作系统,具有高度可定制性、稳定性和安全性,广泛应用于服务器、云计算、物联网等领域。其发展得益于庞大的社区支持,多种发行版如Ubuntu、Debian、Fedora等满足不同需求。
44 4
下一篇
开通oss服务