Docker是什么?

Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从 Apache2.0 协议开源。 Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级、可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。 容器是完全使用沙箱机制,相互之间不会有任何接口(类似 iPhone 的 app),更重要的是容器性能开销极低。

安装要求

Linux服务器centos内核不能低于3.10

查看内核命令

uname -r
3.10.0-1062.18.1.el7.x86_64

安装过要清除

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine

从阿里云加快docker的镜像拉取

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded 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

Docker安装

Docker分为(Docker版本分为CE(社区免费版)和EE(企业版,安全CE)

我们通常所下载的Docker为Docker ce社区版的

运行下面命令下载并安装Docker

sudo yum -y install docker-ce
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: mirrors.bfsu.edu.cn
 * webtatic: us-east.repo.webtatic.com
docker-ce-stable                                                                                                            | 3.5 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                                                                                 |  82 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:20.10.18-3.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-20.10.18-3.el7.x86_64
--> Processing Dependency: containerd.io >= 1.4.1 for package: 3:docker-ce-20.10.18-3.el7.x86_64
--> Processing Dependency: libseccomp >= 2.3 for package: 3:docker-ce-20.10.18-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-20.10.18-3.el7.x86_64
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.18-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
---> Package containerd.io.x86_64 0:1.6.8-3.1.el7 will be installed
---> Package docker-ce-cli.x86_64 1:20.10.18-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.18-3.el7.x86_64
---> Package docker-ce-rootless-extras.x86_64 0:20.10.18-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.18-3.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.18-3.el7.x86_64
---> Package libseccomp.x86_64 0:2.3.1-4.el7 will be installed
--> Running transaction check
---> Package docker-scan-plugin.x86_64 0:0.17.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 slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================
 Package                                   Arch                   Version                                   Repository                        Size
===================================================================================================================================================
Installing:
 docker-ce                                 x86_64                 3:20.10.18-3.el7                          docker-ce-stable                  22 M
Installing for dependencies:
 container-selinux                         noarch                 2:2.119.2-1.911c772.el7_8                 extras                            40 k
 containerd.io                             x86_64                 1.6.8-3.1.el7                             docker-ce-stable                  33 M
 docker-ce-cli                             x86_64                 1:20.10.18-3.el7                          docker-ce-stable                  30 M
 docker-ce-rootless-extras                 x86_64                 20.10.18-3.el7                            docker-ce-stable                 8.5 M
 docker-scan-plugin                        x86_64                 0.17.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
 libseccomp                                x86_64                 2.3.1-4.el7                               base                              56 k
 slirp4netns                               x86_64                 0.4.3-4.el7_8                             extras                            81 k

Transaction Summary
===================================================================================================================================================
Install  1 Package (+9 Dependent packages)

Total download size: 97 M
Installed size: 369 M
Downloading packages:
(1/10): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm                                                                |  40 kB  00:00:00     
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-20.10.18-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-20.10.18-3.el7.x86_64.rpm is not installed
(2/10): docker-ce-20.10.18-3.el7.x86_64.rpm                                                                                 |  22 MB  00:00:02     
(3/10): containerd.io-1.6.8-3.1.el7.x86_64.rpm                                                                              |  33 MB  00:00:05     
(4/10): docker-ce-rootless-extras-20.10.18-3.el7.x86_64.rpm                                                                 | 8.5 MB  00:00:01     
(5/10): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm                                                                             |  54 kB  00:00:00     
(6/10): slirp4netns-0.4.3-4.el7_8.x86_64.rpm                                                                                |  81 kB  00:00:00     
(7/10): libseccomp-2.3.1-4.el7.x86_64.rpm                                                                                   |  56 kB  00:00:00     
(8/10): fuse3-libs-3.6.1-4.el7.x86_64.rpm                                                                                   |  82 kB  00:00:00     
(9/10): docker-scan-plugin-0.17.0-3.el7.x86_64.rpm                                                                          | 3.7 MB  00:00:00     
(10/10): docker-ce-cli-20.10.18-3.el7.x86_64.rpm                                                                                                                                                                     |  30 MB  00:00:04     
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                        12 MB/s |  97 MB  00:00:07     
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 : libseccomp-2.3.1-4.el7.x86_64                                                                                                                                                                                           1/10 
  Installing : docker-scan-plugin-0.17.0-3.el7.x86_64                                                                                                                                                                                  2/10 
  Installing : 1:docker-ce-cli-20.10.18-3.el7.x86_64                                                                                                                                                                                   3/10 
  Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                                                                                                      4/10 
setsebool:  SELinux is disabled.
  Installing : containerd.io-1.6.8-3.1.el7.x86_64                                                                                                                                                                                      5/10 
  Installing : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                                                                                                                        6/10 
  Installing : fuse3-libs-3.6.1-4.el7.x86_64                                                                                                                                                                                           7/10 
  Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                                                                                                                                     8/10 
  Installing : 3:docker-ce-20.10.18-3.el7.x86_64                                                                                                                                                                                       9/10 
  Installing : docker-ce-rootless-extras-20.10.18-3.el7.x86_64                                                                                                                                                                        10/10 
  Verifying  : fuse3-libs-3.6.1-4.el7.x86_64                                                                                                                                                                                           1/10 
  Verifying  : containerd.io-1.6.8-3.1.el7.x86_64                                                                                                                                                                                      2/10 
  Verifying  : docker-ce-rootless-extras-20.10.18-3.el7.x86_64                                                                                                                                                                         3/10 
  Verifying  : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                                                                                                                                     4/10 
  Verifying  : 3:docker-ce-20.10.18-3.el7.x86_64                                                                                                                                                                                       5/10 
  Verifying  : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                                                                                                                        6/10 
  Verifying  : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                                                                                                      7/10 
  Verifying  : libseccomp-2.3.1-4.el7.x86_64                                                                                                                                                                                           8/10 
  Verifying  : 1:docker-ce-cli-20.10.18-3.el7.x86_64                                                                                                                                                                                   9/10 
  Verifying  : docker-scan-plugin-0.17.0-3.el7.x86_64                                                                                                                                                                                 10/10 

Installed:
  docker-ce.x86_64 3:20.10.18-3.el7                                                                                                                                                                                                         

Dependency Installed:
  container-selinux.noarch 2:2.119.2-1.911c772.el7_8    containerd.io.x86_64 0:1.6.8-3.1.el7    docker-ce-cli.x86_64 1:20.10.18-3.el7    docker-ce-rootless-extras.x86_64 0:20.10.18-3.el7    docker-scan-plugin.x86_64 0:0.17.0-3.el7   
  fuse-overlayfs.x86_64 0:0.7.2-6.el7_8                 fuse3-libs.x86_64 0:3.6.1-4.el7         libseccomp.x86_64 0:2.3.1-4.el7          slirp4netns.x86_64 0:0.4.3-4.el7_8                  

Complete!

是否安装成功?

docker version
Version:           20.10.18
 API version:       1.41
 Go version:        go1.18.6
 Git commit:        b40c2f6
 Built:             Thu Sep  8 23:14:08 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
点赞(1) 打赏

Comment list 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部