CentOS 安裝 Docker

本文翻譯自docker官網(wǎng):https://docs.docker.com/engine/install/centos/

Install Docker Engine on CentOS

To get started with Docker Engine on CentOS, make sure you
meet the prerequisites, then
install Docker.

要開(kāi)始在CentOS上使用Docker引擎藤肢,請(qǐng)確保滿足先決條件扭屁,然后安裝Docker规揪。

Prerequisites

OS requirements

To install Docker Engine, you need a maintained version of CentOS 7 or 8.
Archived versions aren't supported or tested.

若要安裝Docker引擎, 你需要CentOS 7或8的維護(hù)版本。 不支持或測(cè)試存檔版本适秩。

The centos-extras repository must be enabled. This repository is enabled by
default, but if you have disabled it, you need to
re-enable it

必須啟用centos-extras存儲(chǔ)庫(kù)巍佑。默認(rèn)情情況下,此存儲(chǔ)庫(kù)處于開(kāi)啟狀態(tài)孔飒,但如果你已禁用它灌闺,你需要重新啟用它。

The overlay2 storage driver is recommended.

建議使用overlay2存儲(chǔ)驅(qū)動(dòng)程序坏瞄。

Uninstall old versions

Older versions of Docker were called docker or docker-engine. If these are
installed, uninstall them, along with associated dependencies.

舊版本的docker稱為dockerdocker-engine桂对。如果安裝了這些,請(qǐng)卸載它們以及相關(guān)依賴項(xiàng)鸠匀。

$ sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

It's OK if yum reports that none of these packages are installed.

如果yum報(bào)告沒(méi)有安裝這些包就OK了蕉斜。

The contents of /var/lib/docker/, including images, containers, volumes, and
networks, are preserved. The Docker Engine package is now called docker-ce.

/var/lib/docker/的內(nèi)容(包括鏡像、容器缀棍、卷宅此、網(wǎng)絡(luò))將被保留。Docker引擎包現(xiàn)在成為docker-ce

Installation methods

You can install Docker Engine in different ways, depending on your needs:

你可以根據(jù)需要以不同的方式安裝Docker Engine:

  • Most users
    set up Docker’s repositories and install
    from them, for ease of installation and upgrade tasks. This is the
    recommended approach.

    大多數(shù)用戶設(shè)置Docker的repositories并從中安裝睦柴,以便安裝和升級(jí)任務(wù)诽凌。這是推薦的方法。

  • Some users download the RPM package and
    install it manually and manage
    upgrades completely manually. This is useful in situations such as installing
    Docker on air-gapped systems with no access to the internet.

    有些用戶下載RPM包并手動(dòng)安裝坦敌,完全手動(dòng)管理升級(jí)侣诵。這在一些情況下很有用,比如在沒(méi)有互聯(lián)網(wǎng)接入的air-gapped(氣隙)系統(tǒng)上安裝Docker狱窘。

  • In testing and development environments, some users choose to use automated
    convenience scripts to install Docker.

    在測(cè)試和開(kāi)發(fā)環(huán)境中杜顺,一些用戶選擇使用自動(dòng)化的便利腳本來(lái)安裝Docker。

Install using the repository

Before you install Docker Engine for the first time on a new host machine, you need
to set up the Docker repository. Afterward, you can install and update Docker
from the repository.

在一臺(tái)新的主機(jī)上首次安裝Docker Engine之前蘸炸,你需要設(shè)置Docker的repository躬络。然后,你可以從該repository安裝和更新Docker搭儒。

Set up the repository

Install the yum-utils package (which provides the yum-config-manager
utility) and set up the stable repository.

安裝yum-utils包(它提供了yum config manager實(shí)用程序)并且設(shè)置穩(wěn)定的repository穷当。

$ sudo yum install -y yum-utils

$ sudo yum-config-manager \
    --add-repo \
    {{ download-url-base }}/docker-ce.repo

Install Docker Engine

  1. Install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:

    安裝最新版本的Docker Engine和contianerd提茁,或者轉(zhuǎn)至下一步安裝特定版本的:

    $ sudo yum install docker-ce docker-ce-cli containerd.io
    

    If prompted to accept the GPG key, verify that the fingerprint matches
    060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, and if so, accept it.

    如果提示接受GPG秘鑰,驗(yàn)證指紋是否與060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35相匹配馁菜,如果匹配茴扁,接受它。

    Docker is installed but not started. The docker group is created, but no users are added to the group.

    Docker已經(jīng)安裝但是并沒(méi)有啟動(dòng)汪疮。docker組已經(jīng)創(chuàng)建峭火,但是沒(méi)有用戶加到該組。

  2. To install a specific version of Docker Engine, list the available versions
    in the repo, then select and install:

    要安裝特定版本的Docker Engine智嚷,在repo中列出所有可用版本卖丸,然后選擇并安裝:

    a. List and sort the versions available in your repo. This example sorts
    results by version number, highest to lowest, and is truncated:

    列出并排序repo中可用的版本。此例子通過(guò)版本號(hào)排序結(jié)果盏道,從高到底稍浆,并被截?cái)啵?/p>

    $ yum list docker-ce --showduplicates | sort -r
    
    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.1.ce-3.el7                    docker-ce-stable
    docker-ce.x86_64  18.06.0.ce-3.el7                    docker-ce-stable
    

    The list returned depends on which repositories are enabled, and is specific
    to your version of CentOS (indicated by the .el7 suffix in this example).

    返回列表取決于你啟用了哪些repositories,并且特定于你的CentOS版本(在本例中以.el7后綴表示)

    b. Install a specific version by its fully qualified package name, which is
    the package name (docker-ce) plus the version string (2nd column)
    starting at the first colon (:), up to the first hyphen, separated by
    a hyphen (-). For example, docker-ce-18.09.1.

    按其完全限定的軟件包名稱(即軟件包名稱(docker ce)加上版本字符串(第2列)摇天,從第一個(gè)冒號(hào)(:)開(kāi)始粹湃,一直到第一個(gè)連字符,用連字符(-)分隔)安裝特定版本泉坐。例如,docker-ce-18.09.1

    $ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
    

    Docker is installed but not started. The docker group is created, but no users are added to the group.

    Docker已經(jīng)安裝但是并沒(méi)有啟動(dòng)裳仆。docker組已經(jīng)創(chuàng)建腕让,但是沒(méi)有用戶加到該組。

  3. Start Docker.

    $ sudo systemctl start docker
    
  4. Verify that Docker Engine is installed correctly by running the hello-world
    image.

    通過(guò)運(yùn)行hello-world鏡像來(lái)驗(yàn)證Docker Engine是否安裝正確歧斟。

    $ sudo docker run hello-world
    

    This command downloads a test image and runs it in a container. When the
    container runs, it prints an informational message and exits.

    該指令下載一個(gè)測(cè)試鏡像并在一個(gè)容器內(nèi)運(yùn)行它纯丸。當(dāng)容器運(yùn)行時(shí),它會(huì)打印一個(gè)信息性的消息并退出静袖。

Docker Engine is installed and running. You need to use sudo to run Docker
commands. Continue to Linux post install to allow
non-privileged users to run Docker commands and for other optional configuration
steps.

Docker Engine已經(jīng)安裝完成并運(yùn)行觉鼻。 你需要使用sudo來(lái)運(yùn)行Docker指令。
繼續(xù)Linux post install 以允許非特權(quán)用戶運(yùn)行Docker指令和其它可選配置步驟队橙。

Upgrade Docker Engine

To upgrade Docker Engine, follow the installation instructions,
choosing the new version you want to install.

跟隨installation instructions 選擇你想要安裝的新版本來(lái)更新Docker Engine坠陈。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市捐康,隨后出現(xiàn)的幾起案子仇矾,更是在濱河造成了極大的恐慌设哗,老刑警劉巖惊畏,帶你破解...
    沈念sama閱讀 216,997評(píng)論 6 502
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件春寿,死亡現(xiàn)場(chǎng)離奇詭異猾封,居然都是意外死亡巡社,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,603評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門(mén)诸尽,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)蠢箩,“玉大人,你說(shuō)我怎么就攤上這事敦锌∪雷罚” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 163,359評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵供屉,是天一觀的道長(zhǎng)行冰。 經(jīng)常有香客問(wèn)我,道長(zhǎng)伶丐,這世上最難降的妖魔是什么悼做? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,309評(píng)論 1 292
  • 正文 為了忘掉前任,我火速辦了婚禮哗魂,結(jié)果婚禮上肛走,老公的妹妹穿的比我還像新娘。我一直安慰自己录别,他們只是感情好朽色,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,346評(píng)論 6 390
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著组题,像睡著了一般葫男。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上崔列,一...
    開(kāi)封第一講書(shū)人閱讀 51,258評(píng)論 1 300
  • 那天梢褐,我揣著相機(jī)與錄音,去河邊找鬼赵讯。 笑死盈咳,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的边翼。 我是一名探鬼主播鱼响,決...
    沈念sama閱讀 40,122評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼组底!你這毒婦竟也來(lái)了丈积?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 38,970評(píng)論 0 275
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤斤寇,失蹤者是張志新(化名)和其女友劉穎桶癣,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體娘锁,經(jīng)...
    沈念sama閱讀 45,403評(píng)論 1 313
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡牙寞,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,596評(píng)論 3 334
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片间雀。...
    茶點(diǎn)故事閱讀 39,769評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡悔详,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出惹挟,到底是詐尸還是另有隱情茄螃,我是刑警寧澤,帶...
    沈念sama閱讀 35,464評(píng)論 5 344
  • 正文 年R本政府宣布连锯,位于F島的核電站归苍,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏运怖。R本人自食惡果不足惜拼弃,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,075評(píng)論 3 327
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望摇展。 院中可真熱鬧吻氧,春花似錦、人聲如沸咏连。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 31,705評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)祟滴。三九已至振惰,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間踱启,已是汗流浹背报账。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,848評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留埠偿,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 47,831評(píng)論 2 370
  • 正文 我出身青樓榜晦,卻偏偏與公主長(zhǎng)得像冠蒋,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子乾胶,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,678評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容