当前位置:   article > 正文

在RedHat上安装docker_redhat 安装docker

redhat 安装docker

redhat上安装docker

这里基于能正常访问到公网!!!

检查系统内核版本,内核要求高于3.10

[root@ssh-server ~]# uname -r
4.18.0-80.el8.x86_64
  • 1
  • 2

设置docker的yum源,方便安装及自动解决依赖

需要确定待安装的机器是否能直接访问外网,否则需要将待安装的docker包及其依赖上传到内部yum仓库或者保存到本地,不做赘述。

[root@ssh-server ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo ##如果没有该命令,请先安装dnf-utils-4.0.2.2-3.el8.noarch
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
[root@ssh-server ~]# yum repolist 
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 1:27:52 ago on Mon 13 Jul 2020 01:16:06 PM CST.
repo id                                                            repo name                                                                                        status
AppStream                                                          App                                                                                              4,672
LiuHaiyang                                                         LiuHaiyang's repo                                                                                1,658
docker-ce-stable                                                   Docker CE Stable - x86_64                                                                           71
epel                                                               Extra Packages for Enterprise Linux 8 - x86_64                                                   5,999
teamviewer                                                         TeamViewer - x86_64                                                                                 93
[root@rhel8 yum.repos.d]# yum list |grep docker #查看新添加的yum源是否有docker镜像
containerd.io.x86_64                                 1.2.0-3.el7                                          docker-ce-stable
docker-ce.x86_64                                     3:19.03.12-3.el7                                     docker-ce-stable
docker-ce-cli.x86_64                                 1:19.03.12-3.el7                                     docker-ce-stable
docker-ce-selinux.noarch                             17.03.3.ce-1.el7                                     docker-ce-stable
pcp-pmda-docker.x86_64                               4.3.0-3.el8                                          AppStream       
podman-docker.noarch                                 1.0.0-2.git921f98f.module+el8+2785+ff8a053f          AppStream       

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

如果已安装docker需要先卸载

[root@rhel8 yum.repos.d]# rpm -qa|grep docker
podman-docker-1.0.0-2.git921f98f.module+el8+2785+ff8a053f.noarch
[root@rhel8 yum.repos.d]# yum -y remove docker
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Dependencies resolved.
==========================================================================================================================================================================
 Package                            Arch                        Version                                                             Repository                       Size
==========================================================================================================================================================================
Removing:
 podman-docker                      noarch                      1.0.0-2.git921f98f.module+el8+2785+ff8a053f                         @AppStream                      3.5 k

Transaction Summary
==========================================================================================================================================================================
Remove  1 Package

Freed space: 3.5 k
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                  1/1 
  Erasing          : podman-docker-1.0.0-2.git921f98f.module+el8+2785+ff8a053f.noarch                                                                                 1/1 
  Running scriptlet: podman-docker-1.0.0-2.git921f98f.module+el8+2785+ff8a053f.noarch                                                                                 1/1 
  Verifying        : podman-docker-1.0.0-2.git921f98f.module+el8+2785+ff8a053f.noarch                                                                                 1/1 
Installed products updated.

Removed:
  podman-docker-1.0.0-2.git921f98f.module+el8+2785+ff8a053f.noarch                                                                                                        

Complete!

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34

指定安装的docker版本及检查

可先查看yum源中提供的docker的版本

[root@rhel8 yum.repos.d]# yum list docker-ce --showduplicates | sort -r
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:04:18 ago on Mon 13 Jul 2020 03:02:57 PM CST.
docker-ce.x86_64            3:19.03.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.12-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.11-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.10-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.0-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.0-3.el7                     docker-ce-stable
docker-ce.x86_64            18.06.3.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.2.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.1.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.0.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            18.03.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.3.ce-1.el7                    docker-ce-stable
docker-ce.x86_64            17.03.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.0.ce-1.el7.centos             docker-ce-stable
Available Packages
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46

由于安装高版本的docker对containerd.io的版本有要求,这里我们先安装低版本的docker包。也可以选择手动安装containerd.io。

[root@rhel8 yum.repos.d]# yum -y install docker-ce-18.06.3.ce-3.el7.x86_64
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Docker CE Stable - x86_64                                                                                                                 1.3 kB/s | 3.5 kB     00:02    
Dependencies resolved.
==========================================================================================================================================================================
 Package                               Arch                               Version                                      Repository                                    Size
==========================================================================================================================================================================
Installing:
 docker-ce                             x86_64                             18.06.3.ce-3.el7                             docker-ce-stable                              41 M
Installing dependencies:
 libcgroup                             x86_64                             0.41-19.el8                                  LiuHaiyang                                    70 k

Transaction Summary
==========================================================================================================================================================================
Install  2 Packages

Total size: 41 M
Total download size: 41 M
Installed size: 168 M
Downloading Packages:
docker-ce-18.06.3.ce-3.el7.x86_64.rpm                                                                                                     1.5 MB/s |  41 MB     00:26    
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                     1.5 MB/s |  41 MB     00:26     
warning: /var/cache/dnf/docker-ce-stable-091d8a9c23201250/packages/docker-ce-18.06.3.ce-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Docker CE Stable - x86_64                                                                                                                 1.3 kB/s | 1.6 kB     00:01    
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://download.docker.com/linux/centos/gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                  1/1 
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                                                                     1/2 
  Installing       : libcgroup-0.41-19.el8.x86_64                                                                                                                     1/2 
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                                                                     1/2 
  Running scriptlet: docker-ce-18.06.3.ce-3.el7.x86_64                                                                                                                2/2 
  Installing       : docker-ce-18.06.3.ce-3.el7.x86_64                                                                                                                2/2 
  Running scriptlet: docker-ce-18.06.3.ce-3.el7.x86_64                                                                                                                2/2 
  Verifying        : libcgroup-0.41-19.el8.x86_64                                                                                                                     1/2 
  Verifying        : docker-ce-18.06.3.ce-3.el7.x86_64                                                                                                                2/2 
Installed products updated.

Installed:
  docker-ce-18.06.3.ce-3.el7.x86_64                                                      libcgroup-0.41-19.el8.x86_64                                                     

Complete!
[root@rhel8 yum.repos.d]# 
[root@rhel8 yum.repos.d]# docker version
Client:
 Version:           18.06.3-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        d7080c1
 Built:             Wed Feb 20 02:26:51 2019
 OS/Arch:           linux/amd64
 Experimental:      false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64

如果想按照docker包的较新版本,先手动安装containerd.io。

curl去该目录下选择并下载想要的containerd.io版本

[root@rhel8 yum.repos.d]# curl -O https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.10-3.2.el7.x86_64.rpm
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 23.1M  100 23.1M    0     0  4783k      0  0:00:04  0:00:04 --:--:-- 5132k

  • 1
  • 2
  • 3
  • 4
  • 5

yum安装containerd.io

[root@rhel8 yum.repos.d]# yum -y install containerd.io-1.2.10-3.2.el7.x86_64.rpm
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:08:32 ago on Mon 13 Jul 2020 03:15:59 PM CST.
Dependencies resolved.
==========================================================================================================================================================================
 Package                                   Arch                               Version                                      Repository                                Size
==========================================================================================================================================================================
Installing:
 containerd.io                             x86_64                             1.2.10-3.2.el7                               @commandline                              23 M
     replacing  runc.x86_64 1.0.0-54.rc5.dev.git2abd837.module+el8+2769+577ad176

Transaction Summary
==========================================================================================================================================================================
Install  1 Package

Total size: 23 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                  1/1 
  Installing       : containerd.io-1.2.10-3.2.el7.x86_64                                                                                                              1/2 
  Running scriptlet: containerd.io-1.2.10-3.2.el7.x86_64                                                                                                              1/2 
  Obsoleting       : runc-1.0.0-54.rc5.dev.git2abd837.module+el8+2769+577ad176.x86_64                                                                                 2/2 
  Running scriptlet: runc-1.0.0-54.rc5.dev.git2abd837.module+el8+2769+577ad176.x86_64                                                                                 2/2 
  Verifying        : containerd.io-1.2.10-3.2.el7.x86_64                                                                                                              1/2 
  Verifying        : runc-1.0.0-54.rc5.dev.git2abd837.module+el8+2769+577ad176.x86_64                                                                                 2/2 
Installed products updated.

Installed:
  containerd.io-1.2.10-3.2.el7.x86_64                                                                                                                                     

Complete!

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

安装新版本的docker

[root@rhel8 yum.repos.d]# yum install -y docker-ce
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:10:23 ago on Mon 13 Jul 2020 03:15:59 PM CST.
Dependencies resolved.
==========================================================================================================================================================================
 Package                                  Arch                              Version                                     Repository                                   Size
==========================================================================================================================================================================
Installing:
 docker-ce                                x86_64                            3:19.03.12-3.el7                            docker-ce-stable                             24 M
Installing dependencies:
 libcgroup                                x86_64                            0.41-19.el8                                 LiuHaiyang                                   70 k
 docker-ce-cli                            x86_64                            1:19.03.12-3.el7                            docker-ce-stable                             38 M

Transaction Summary
==========================================================================================================================================================================
Install  3 Packages

Total size: 62 M
Total download size: 62 M
Installed size: 263 M
Downloading Packages:
(1/2): docker-ce-19.03.12-3.el7.x86_64.rpm                                                                                                3.8 MB/s |  24 MB     00:06    
(2/2): docker-ce-cli-19.03.12-3.el7.x86_64.rpm                                                                                            3.8 MB/s |  38 MB     00:10    
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                     6.2 MB/s |  62 MB     00:10     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                  1/1 
  Installing       : docker-ce-cli-1:19.03.12-3.el7.x86_64                                                                                                            1/3 
  Running scriptlet: docker-ce-cli-1:19.03.12-3.el7.x86_64                                                                                                            1/3 
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                                                                     2/3 
  Installing       : libcgroup-0.41-19.el8.x86_64                                                                                                                     2/3 
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                                                                     2/3 
  Installing       : docker-ce-3:19.03.12-3.el7.x86_64                                                                                                                3/3 
  Running scriptlet: docker-ce-3:19.03.12-3.el7.x86_64                                                                                                                3/3 
  Verifying        : libcgroup-0.41-19.el8.x86_64                                                                                                                     1/3 
  Verifying        : docker-ce-3:19.03.12-3.el7.x86_64                                                                                                                2/3 
  Verifying        : docker-ce-cli-1:19.03.12-3.el7.x86_64                                                                                                            3/3 
Installed products updated.

Installed:
  docker-ce-3:19.03.12-3.el7.x86_64                       libcgroup-0.41-19.el8.x86_64                       docker-ce-cli-1:19.03.12-3.el7.x86_64                      

Complete!
[root@rhel8 yum.repos.d]# docker version
Client: Docker Engine - Community
 Version:           19.03.12
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        48a66213fe
 Built:             Mon Jun 22 15:46:54 2020
 OS/Arch:           linux/amd64
 Experimental:      false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60

启动docker

[root@rhel8 yum.repos.d]# systemctl start docker    #启动docker
[root@rhel8 yum.repos.d]# systemctl status docker   #查看docker
[root@rhel8 yum.repos.d]# systemctl stop docker     #停止docker
[root@rhel8 yum.repos.d]# systemctl enable docker   #开机自启动docker
  • 1
  • 2
  • 3
  • 4
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/576158
推荐阅读
相关标签
  

闽ICP备14008679号