Centos7 Docker安裝與卸載

安裝Docker

環(huán)境準(zhǔn)備

  1. CentOS7

環(huán)境查看

#系統(tǒng)內(nèi)核是3.10以上
[root@VM_0_8_centos ~]# uname -r
3.10.0-862.el7.x86_64
#系統(tǒng)版本
[root@VM_0_8_centos ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"


安裝

查看官方文檔:https://docs.docker.com/engine/install/centos/

#1. 卸載舊版本
$ sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
#2.安裝需要的包
$ sudo yum install -y yum-utils

#3.設(shè)置鏡像倉庫(使用國內(nèi)阿里云)
$ sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    
#4.更新yum軟件包索引
[root@VM_0_8_centos ~]# yum makecache fast


#5.安裝Docker 相關(guān)源(最新)
$ sudo yum install docker-ce docker-ce-cli containerd.io

#6.啟動(dòng)docker
$ sudo systemctl start docker

#7.查看Docker
[root@VM_0_8_centos ~]# docker version
Client: Docker Engine - Community
 Version:           19.03.13
 API version:       1.40
 Go version:        go1.13.15
 Git commit:        4484c46d9d
 Built:             Wed Sep 16 17:03:45 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.13
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       4484c46d9d
  Built:            Wed Sep 16 17:02:21 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.3.7
  GitCommit:        8fba4e9a7d01810a393d5d25a3621dc101981175
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

#8. 運(yùn)行docker hello-world示例 (首次執(zhí)行會(huì)下載)
$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:4cf9c47f86df71d48364001ede3a4fcd85ae80ce02ebad74156906caff5378bc
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

#9.查看鏡像
[root@VM_0_8_centos ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              bf756fb1ae65        9 months ago        13.3kB


最后一步留攒,出現(xiàn) Hello from Docker! 表示Docker安裝完成!

卸載Docker

#1.卸載安裝包
$ sudo yum remove docker-ce docker-ce-cli containerd.io

#2.卸載默認(rèn)工作路徑
$ sudo rm -rf /var/lib/docker

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末樊破,一起剝皮案震驚了整個(gè)濱河市驮配,隨后出現(xiàn)的幾起案子记劝,更是在濱河造成了極大的恐慌睡陪,老刑警劉巖赏僧,帶你破解...
    沈念sama閱讀 222,590評(píng)論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件油猫,死亡現(xiàn)場(chǎng)離奇詭異稠茂,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)情妖,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,157評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門睬关,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人毡证,你說我怎么就攤上這事电爹。” “怎么了料睛?”我有些...
    開封第一講書人閱讀 169,301評(píng)論 0 362
  • 文/不壞的土叔 我叫張陵丐箩,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我恤煞,道長(zhǎng)屎勘,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 60,078評(píng)論 1 300
  • 正文 為了忘掉前任居扒,我火速辦了婚禮概漱,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘喜喂。我一直安慰自己瓤摧,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 69,082評(píng)論 6 398
  • 文/花漫 我一把揭開白布玉吁。 她就那樣靜靜地躺著照弥,像睡著了一般。 火紅的嫁衣襯著肌膚如雪进副。 梳的紋絲不亂的頭發(fā)上这揣,一...
    開封第一講書人閱讀 52,682評(píng)論 1 312
  • 那天,我揣著相機(jī)與錄音影斑,去河邊找鬼给赞。 笑死,一個(gè)胖子當(dāng)著我的面吹牛鸥昏,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播姐帚,決...
    沈念sama閱讀 41,155評(píng)論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼吏垮,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起膳汪,我...
    開封第一講書人閱讀 40,098評(píng)論 0 277
  • 序言:老撾萬榮一對(duì)情侶失蹤唯蝶,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后遗嗽,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體粘我,經(jīng)...
    沈念sama閱讀 46,638評(píng)論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,701評(píng)論 3 342
  • 正文 我和宋清朗相戀三年痹换,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了征字。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,852評(píng)論 1 353
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡娇豫,死狀恐怖匙姜,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情冯痢,我是刑警寧澤氮昧,帶...
    沈念sama閱讀 36,520評(píng)論 5 351
  • 正文 年R本政府宣布,位于F島的核電站浦楣,受9級(jí)特大地震影響袖肥,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜振劳,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,181評(píng)論 3 335
  • 文/蒙蒙 一椎组、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧澎迎,春花似錦庐杨、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,674評(píng)論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至哮洽,卻和暖如春填渠,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背鸟辅。 一陣腳步聲響...
    開封第一講書人閱讀 33,788評(píng)論 1 274
  • 我被黑心中介騙來泰國打工氛什, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人匪凉。 一個(gè)月前我還...
    沈念sama閱讀 49,279評(píng)論 3 379
  • 正文 我出身青樓枪眉,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國和親再层。 傳聞我的和親對(duì)象是個(gè)殘疾皇子贸铜,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,851評(píng)論 2 361