前言
目前,CentOS 仅发行版本中的内核支持 Docker
Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上
Docker 运行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本
本文以CentOS7 内核版本3.10.0-957,docker-ce版本 18.09.4 为例
一、基础环境
1.1 操作系统
1.2 Docker版本:18.09.4 官方下载地址
1.3 参考文档:官方文档:https://docs.docker.com/install/linux/docker-ce/binaries/#install-static-binaries
二、安装步骤
2.1 检验系统内核版本:
[root@localhost ~]# uname -r
2.2 提前下载好docker的tar.gz文件,地址 点击这里
2.3 上传到离线服务器上
2.4 解压 docker-18.09.4-ce.tgz
[root@localhost ~]# tar -xvf docker-18.09.4-ce.tgz
2.5 将解压出来的docker文件夹内所有内容移动到 /usr/bin/ 目录下
[root@localhost ~]# cp docker/* /usr/bin/
2.6 将docker注册为service
[root@localhost ~]# vi /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
2.7 添加docker.service文件权限
[root@localhost ~]# chmod +x /etc/systemd/system/docker.service
2.8 启动docker并设置开机自启
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker.service
2.9 验证一下
[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since 五 2019-08-02 08:53:36 CST; 4 days ago
Docs: https://docs.docker.com
Main PID: 14136 (dockerd)
Tasks: 295
Memory: 809.3M
CGroup: /system.slice/docker.service
看到running就表示运行起来了
还可以查看一下docker版本
[root@localhost ~]# docker -v
Docker version 18.09.4, build d14af54266
至此,安装成功,其他版本的安装也是类似的

2842

被折叠的 条评论
为什么被折叠?



