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

一、实验背景

现在docker将版本分为企业EE版以及社区CE版。

CentOS7.x上的docker安装,主要有两种方式:rpm yum安装和二进制文件安装,其他Linux发行版安装方式类似。

Docker的rpm yum安装需要添加docker官方,然后安装相应的docker社区版,如果内网离线安装的话,需要先在联网机器上下载主包及其依赖,在内网机器搭建本地yum源,执行安装。

Docker的二进制文件安装就省事多了,直接下载官方二进制安装包,编写服务的启动脚本或者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的二进制安装


下载docker二进制安装包

# 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


 创建docker服务的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

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


启动docker服务并设为开机自

# systemctl daemon-reload

# systemctl start docker

# systemctl  status docker

# systemctl enable docker

# docker  info

# docker  version



四、参考

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容