Docker——CentOS7安裝Docker環境

CentOs 7 安裝 Docker

​ Docker 是一個開源的應用容器引擎,是一個輕量級容器技術,Docker 支持將軟件編譯成一個鏡像,然後在鏡像中對各種軟件做好配置,將鏡像發佈出去,使用者們都可以直接使用這個鏡像、

​ 運行中的這個鏡像被稱爲容器,容器的啓動是非常快速的,下面我們就來介紹如何在 CentOS 7 系統中安裝 Docker

準備工作

​ 首先,Docker 官方要求 Linux 內核版本必須在3.8以上,建議3.10以上,我們可以使用uname -a指令來查看內核版本

[stephen@localhost ~]$ uname -a
Linux localhost.localdomain 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

​ 我這裏已經是3.10以上的版本了,如果不是的話,我們需要使用sudo yum update指令來更新軟件包及內核

[stephen@localhost ~]$ sudo yum update

我們信任您已經從系統管理員那裏瞭解了日常注意事項。
總結起來無外乎這三點:

    #1) 尊重別人的隱私。
    #2) 輸入前要先考慮(後果和風險)。
    #3) 權力越大,責任越大。

[sudo] stephen 的密碼:
已加載插件:fastestmirror, langpacks
base                                                     | 3.6 kB     00:00     
extras                                                   | 2.9 kB     00:00     
updates                                                  | 2.9 kB     00:00     
(1/4): extras/7/x86_64/primary_db                          | 165 kB   00:00     
(2/4): base/7/x86_64/group_gz                              | 165 kB   00:00     
(3/4): base/7/x86_64/primary_db                            | 6.0 MB   00:04     
(4/4): updates/7/x86_64/primary_db                         | 7.6 MB   00:07     
Determining fastest mirrors
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
正在解決依賴關係
--> 正在檢查事務
---> 軟件包 GeoIP.x86_64.0.1.5.0-11.el7 將被 升級
---> 軟件包 GeoIP.x86_64.0.1.5.0-14.el7 將被 更新
--> 正在處理依賴關係 geoipupdate,它被軟件包 GeoIP-1.5.0-14.el7.x86_64 需要
---> 軟件包 ModemManager.x86_64.0.1.6.0-2.el7 將被 升級
---> 軟件包 ModemManager.x86_64.0.1.6.10-3.el7_6 將被 更新
---> 軟件包 ModemManager-glib.x86_64.0.1.6.0-2.el7 將被 升級
......
......
......
  zenity.x86_64 0:3.28.1-1.el7                                                  
  zlib.x86_64 0:1.2.7-18.el7                                                    

替代:
  caribou.x86_64 0:0.4.21-1.el7                                                 
  caribou-gtk2-module.x86_64 0:0.4.21-1.el7                                     
  caribou-gtk3-module.x86_64 0:0.4.21-1.el7                                     
  gnome-dictionary-libs.x86_64 0:3.20.0-1.el7                                   
  gnome-tweak-tool.noarch 0:3.22.0-1.el7                                        
  grub2.x86_64 1:2.02-0.64.el7.centos                                           
  grub2-tools.x86_64 1:2.02-0.64.el7.centos                                     
  pyatspi.noarch 0:2.20.3-1.el7                                                 
  python2-caribou.noarch 0:0.4.21-1.el7                                         
  urw-fonts.noarch 0:2.4-16.el7                                                 

完畢!

​ 接下來我們就可以安裝 Docker 了

安裝 Docker

​ 檢測過內核版本後,我們就可以使用yum install docker命令安裝 Docker,我們需要使用 root 權限來操作

[stephen@localhost ~]$ su root
密碼:
[root@localhost stephen]# yum install docker
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
正在解決依賴關係
--> 正在檢查事務
---> 軟件包 docker.x86_64.2.1.13.1-109.gitcccb291.el7.centos 將被 安裝
--> 正在處理依賴關係 docker-common = 2:1.13.1-109.gitcccb291.el7.centos,它被軟件包 2:docker-1.13.1-109.gitcccb291.el7.centos.x86_64 需要
--> 正在處理依賴關係 docker-client = 2:1.13.1-109.gitcccb291.el7.centos,它被軟件包 2:docker-1.13.1-109.gitcccb291.el7.centos.x86_64 需要
--> 正在處理依賴關係 subscription-manager-rhsm-certificates,它被軟件包 2:docker-1.13.1-109.gitcccb291.el7.centos.x86_64 需要
......
......
  container-selinux.noarch 2:2.107-3.el7                                        
  container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7                      
  containers-common.x86_64 1:0.1.37-3.el7.centos                                
  docker-client.x86_64 2:1.13.1-109.gitcccb291.el7.centos                       
  docker-common.x86_64 2:1.13.1-109.gitcccb291.el7.centos                       
  libyaml.x86_64 0:0.1.4-11.el7_0                                               
  oci-register-machine.x86_64 1:0-6.git2b44233.el7                              
  oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6                            
  oci-umount.x86_64 2:2.5-3.el7                                                 
  python-pytoml.noarch 0:0.1.14-1.git7dea353.el7                                
  subscription-manager-rhsm-certificates.x86_64 0:1.24.13-4.el7.centos          

完畢!

啓動 Docker

​ 上述步驟執行結束並出現**完畢!**字樣,說明我們已經在 CentOS 系統上成功安裝了 Docker,我們通過執行systemctl start docker啓動 Docker 並使用docker -v查看我們 Docker 的版本

[root@localhost stephen]# systemctl start docker
[root@localhost stephen]# docker -v
Docker version 1.13.1, build cccb291/1.13.1

​ 到這裏,我們的 Docker 就已經成功的安裝在 CentOS 操作系統中了,但是我們沒此重啓操作系統都要重啓 Docker

設置 Docker 的自啓動

​ 通過使用systemctl enable docker可以設置 Docker 的開機自啓動

[root@localhost stephen]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

關閉 Docker

​ 使用systemctl stop docker命令可以關閉 Docker

[root@localhost stephen]# systemctl stop docker
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章