【Docker】CentOS7.x上docker的安裝方式

一、實(shí)驗(yàn)背景

現(xiàn)在docker將版本分為企業(yè)EE版以及社區(qū)CE版。

Docker CE 在 17.03 版本之前叫 Docker Engine,版本號(hào)范圍:?0.1.0 ~ 1.13.1。

從 17.03 版本開(kāi)始新的發(fā)布方案 ( 命名變動(dòng) / 發(fā)布周期的改善 / 版本號(hào)方案變更 )。

在 2017 年 3 月 2 日, docker 團(tuán)隊(duì)宣布企業(yè)版 Docker Enterprise Edition ( EE ) 發(fā)布. 為了一致, 免費(fèi)的 Docker Engine 改名為 Docker Community Edition ( CE ), 并且采用基于時(shí)間的版本號(hào)方案. 就在這一天, Docker EE 和 Docker CE 的 17.03 版本發(fā)布, 這也是第一個(gè)采用新的版本號(hào)方案的版本。

Docker CE/EE 每個(gè)季度發(fā)布一次季度版本, 也就是說(shuō)每年會(huì)發(fā)布 4 個(gè)季度版本, 17.03, 17.06, 17.09, 17.12 就是 2017 年的 4 個(gè)季度版本的版本號(hào), 同時(shí) Docker CE 每個(gè)月還會(huì)發(fā)布一個(gè) EDGE 版本,比如 17.04, 17.05, 17.07, 17.08, 17.10, 17.11,Docker CE 季度版本自發(fā)布后會(huì)有 4 個(gè)月的維護(hù)期。



CentOS7.x上的docker安裝,主要有兩種方式:rpm yum安裝和二進(jìn)制文件安裝,其他Linux發(fā)行版安裝方式類(lèi)似。

1.Docker的rpm yum安裝需要添加docker官方,然后安裝相應(yīng)的docker社區(qū)版,如果內(nèi)網(wǎng)離線安裝的化,需要先在聯(lián)網(wǎng)機(jī)器上下載主包及其依賴(lài),在內(nèi)網(wǎng)機(jī)器搭建本地yum源,執(zhí)行安裝。

2.Docker的二進(jìn)制文件安裝就省事多了,直接下載官方二進(jìn)制安裝包(無(wú)需編譯,解壓即用),編寫(xiě)服務(wù)的啟動(dòng)腳本或者Unit文件。

下面我們分別介紹兩種安裝方式,感受一下安裝差異。


二、Docker的yum安裝

# yum -y install? yum-utils device-mapper-persistent-data lvm2

# yum-config-manager? --add-repo? ? https://download.docker.com/linux/centos/docker-ce.repo

# yum list docker-ce? --showduplicates | sort? -r

#? yum -y install docker-ce-18.06.0.ce

# systemctl? start docker

# systemctl? status docker

# systemctl? enable? docker

# docker version


三、Docker的二進(jìn)制安裝

下載docker二進(jìn)制安裝包

# yum? -y install? ?wget?

# wget? ?https://download.docker.com/linux/static/stable/x86_64/docker-18.06.0-ce.tgz


#? tar -zxf? ?docker-18.06.0-ce.tgz

#? ll? ?./docker

# cp ./docker/docker*? ?/usr/bin

?創(chuàng)建docker服務(wù)的unit文件

# vim ?/etc/systemd/system/docker.service

##############################################################

[Unit]

Description=Docker Application Container Engine

Documentation=https://docs.docker.com

After=network-online.target firewalld.service

Wants=network-online.target

[Service]

Type=notify

# the default is not to use systemd for cgroups because the delegate issues still

# exists and systemd currently does not support the cgroup feature set required

# for containers run by docker

ExecStart=/usr/bin/dockerd

ExecReload=/bin/kill -s HUP $MAINPID

# Having non-zero Limit*s causes performance problems due to accounting overhead

# in the kernel. We recommend using cgroups to do container-local accounting.

LimitNOFILE=infinity

LimitNPROC=infinity

LimitCORE=infinity

# Uncomment TasksMax if your systemd version supports it.

# Only systemd 226 and above support this version.

#TasksMax=infinity

TimeoutStartSec=0

# set delegate yes so that systemd does not reset the cgroups of docker containers

Delegate=yes

# kill only the docker process, not all processes in the cgroup

KillMode=process

# restart the docker process if it exits prematurely

Restart=on-failure

StartLimitBurst=3

StartLimitInterval=60s

[Install]

WantedBy=multi-user.target

##############################################

啟動(dòng)docker服務(wù)并設(shè)為開(kāi)機(jī)自

# systemctl daemon-reload

# systemctl start docker

# systemctl ?status docker

# systemctl enable docker

# docker ?info

# docker ?version



四、設(shè)置鏡像加速


#? curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io

#? systemctl restart docker


五、參考


https://download.docker.com/linux/static/edge/x86_64

https://docs.docker.com/engine/reference/commandline/dockerd

https://github.com/moby/moby/releases

https://github.com/moby/moby/blob/master/contrib/init/systemd/docker.service


moby/moby

https://github.com/moby/moby/blob/master/CHANGELOG.md

Docker Engine release notes

https://docs.docker.com/release-notes/docker-engine

About Docker Engine - Community

https://docs.docker.com/install

Announcing Docker Enterprise Edition

https://blog.docker.com/2017/03/docker-enterprise-edition

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容