確認安裝環境:Redhat 7.6
[root@localhost ~]# mount /dev/sr0 /media/ #掛載磁盤
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# yum-config-manager --add-repo=file:///media/ #添加yum倉庫
注意:添加系統ISO為本地YUM倉庫後,需要在.repo配置文件裡添加gpgcheck=0的配置內容,否則用本地庫安裝軟件會失敗。
[root@localhost ~]# rpm -qa | grep libseccomp* #檢查依賴包是否安裝
libseccomp-2.3.1-3.el7.x86_64
[root@localhost ~]# rpm -qa | grep container-selinux* #檢查依賴包是否安裝
從阿里開源鏡像站就可以下載該包,不安裝這個軟件包,docker會無法安裝
<code>[root@localhost ~]# rpm -ivh container-selinux-2.74-1.el7.noarch.rpm
warning: container-selinux-2.74-1.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:container-selinux-2:2.74-1.el7 ################################# [100%]
setsebool: SELinux is disabled./<code>
下載特定的docker軟件包
<code>[root@localhost ~]# wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-18.06.1.ce-3.el7.x86_64.rpm
--2019-03-29 05:57:42-- https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-18.06.1.ce-3.el7.x86_64.rpm
Resolving download.docker.com (download.docker.com)... 54.192.151.75, 54.192.151.52, 54.192.151.81, ...
Connecting to download.docker.com (download.docker.com)|54.192.151.75|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 42712724 (41M) [binary/octet-stream]
Saving to: ‘docker-ce-18.06.1.ce-3.el7.x86_64.rpm’
0% [ ] 0 --.-K/s
……
100%[=========================================================================================================================================>] 42,712,724 216KB/s in 98s
2019-03-29 05:59:21 (424 KB/s) - ‘docker-ce-18.06.1.ce-3.el7.x86_64.rpm’ saved [42712724/42712724]
[root@localhost ~]# ls
anaconda-ks.cfg container-selinux-2.74-1.el7.noarch.rpm docker-ce-18.06.1.ce-3.el7.x86_64.rpm original-ks.cfg/<code>
配置docker YUM倉庫
<code>[root@localhost ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo/<code>
查看系統下的YUM倉庫列表
<code>[root@localhost ~]# yum repolist all
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
docker-ce-stable | 3.5 kB 00:00:00
(2/2): docker-ce-stable/x86_64/primary_db 0% [ ] 0.0 B/s | 0 B --:--:-- ETA
(1/2): docker-ce-stable/x86_64/updateinfo | 55 B 00:00:01
(2/2): docker-ce-stable/x86_64/primary_db | 26 kB 00:00:01
repo id repo name status
docker-ce-edge/x86_64 Docker CE Edge - x86_64 disabled
docker-ce-edge-debuginfo/x86_64 Docker CE Edge - Debuginfo x86_64 disabled
docker-ce-edge-source Docker CE Edge - Sources disabled
docker-ce-nightly/x86_64 Docker CE Nightly - x86_64 disabled
docker-ce-nightly-debuginfo/x86_64 Docker CE Nightly - Debuginfo x86_64 disabled
docker-ce-nightly-source Docker CE Nightly - Sources disabled
docker-ce-stable/x86_64 Docker CE Stable - x86_64 enabled: 39
docker-ce-stable-debuginfo/x86_64 Docker CE Stable - Debuginfo x86_64 disabled
docker-ce-stable-source Docker CE Stable - Sources disabled
docker-ce-test/x86_64 Docker CE Test - x86_64 disabled
docker-ce-test-debuginfo/x86_64 Docker CE Test - Debuginfo x86_64 disabled
docker-ce-test-source Docker CE Test - Sources disabled
media_ added from: file:///media/ enabled: 5,152
repolist: 5,191/<code>
查看本地系統中存在的repo配置文件
[root@localhost yum.repos.d]# ls
docker-ce.repo media_.repo redhat.repo
配置docker YUM倉庫,將密鑰檢查禁用
[root@localhost yum.repos.d]# vim docker-ce.repo(gpgcheck=1-->gpgcheck=0)
查看所有倉庫中所有docker版本,並選擇特定版本安裝
<code>[root@localhost ~]# yum list docker-ce --showduplicates | sort -r
This system is not registered with an entitlement server. You can use subscription-manager to register.
: manager
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
Installed Packages
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.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/<code>
安裝Docker,選的是18.06.1.ce-3.el7
<code>[root@localhost ~]# yum install docker-ce-18.06.1.ce-3.el7
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
docker-ce-stable | 3.5 kB 00:00:00
media_ | 4.3 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:18.06.1.ce-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
docker-ce x86_64 18.06.1.ce-3.el7 docker-ce-stable 41 M
Transaction Summary
=========================================================================================================================================
Install 1 Package
Total download size: 41 M
Installed size: 41 M
Is this ok [y/d/N]: y
Downloading packages:
docker-ce-18.06.1.ce-3.el7.x86_64.rpm 0% [ ] 0.0 B/s | 0 B --:--:-- ETA
……
docker-ce-18.06.1.ce-3.el7.x86_64.rpm 99% [============================================================================================-] 2.3 MB/s | 41 MB 00:00:00 ETA
docker-ce-18.06.1.ce-3.el7.x86_64.rpm | 41 MB 00:00:26
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : docker-ce-18.06.1.ce-3.el7.x86_64 [ ] 1/1
……
Installing : docker-ce-18.06.1.ce-3.el7.x86_64 [######################################################################################################################################### ] 1/1
Installing : docker-ce-18.06.1.ce-3.el7.x86_64 1/1
media_/productid | 1.6 kB 00:00:00
Verifying : docker-ce-18.06.1.ce-3.el7.x86_64 1/1
Installed:
docker-ce.x86_64 0:18.06.1.ce-3.el7
Complete!/<code>
啟動docker
[root@localhost ~]# systemctl start docker.service
設置開機啟動docker
[root@localhost yum.repos.d]# systemctl enable docker
驗證是否安裝成功
<code>[root@localhost ~]# docker
docker docker-containerd docker-containerd-ctr docker-containerd-shim dockerd docker-init docker-proxy docker-runc
[root@localhost ~]# docker version
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:23:03 2018
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:25:29 2018
OS/Arch: linux/amd64
Experimental: false/<code>
閱讀更多 挨踢人 的文章