Linux基操:yum安裝docker


前言:

yum是一個包管理工具,就像npm一樣,在此命令下加包名就是在線下載命令

yum -y [包名]  #在線下載命令

注意:-y的作用就是在安裝過程中用戶默認一切詢問都以’y‘確認,比如:是否安裝(Y/N),默認Y

本文是從安裝yum環境開始的,如果已經有yum環境就直接看docker安裝,

 

一,yum 安裝 gcc&&gcc-c++

gcc和c++都是包,gcc和gcc-c++是代碼編譯軟件(c&&c++),這是必備的所以需要當作基本環境安裝

yum -y install gcc
yum -y install gcc-c++

也可以合並
yum -y install gcc gcc-c++

 

二,安裝docker

按照官網文檔安裝步驟安裝最好,鏈接:https://docs.docker.com/engine/install/centos/

1.卸載舊版本

 
         
$ sudo 暫時切換到超級用戶模式以執行超級用戶權限,一般是給沒有root的普通用戶做安裝使用
$ sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

2.安裝docker軟件包

$ sudo yum install -y yum-utils

3.設置stable鏡像

# 錯誤,這個是官方的,太慢容易出錯
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
## 報錯
[Errno 14] curl#35 - TCP connection reset by peer
[Errno 12] curl#35 - Timeout

# 正確推薦使用國內的,阿里
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

4.更新軟件包索引

#centos7
yum makecache fast

#centos8
yum makecache

5.安裝Docker CE

yum -y install docker-ce docker-ce-cli containerd.io

6.啟動docker

systemctl start docker

7.測試

docker version  #查看版本

docker run hello-world  #通過運行hello-world 鏡像像來驗證是否正確安裝了Docker Engine 

docker images  #查看本地鏡像信息,helloworld是否已下載到本地

8,想用什么鏡像如oracle,mysql,redis等鏡像可以去docker官方庫去拉取,命令參考

docker run hello-world  #通過運行hello-world 鏡像像來驗證是否正確安裝了Docker Engine 。

  

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM