Docker 18.09 离线安装
docker
目录
{{TOC}}
背景环境说明
操作系统: Redhat 7.5 X86
内核: 3.10.0-862.el7.x86_64
需要离线安装docker 18.09
网上很多种方式,yum安装什么的,总是会缺各种包。不建议使用。 直接上大招, 使用binaries 直接安装。
主要步骤
- 准备工作,下载bin包
- 配置Docker的一些配置文件
- 验证Docker
详细步骤
1. 检查ROOT权限(可选)
如果已经有管理员权限,可以跳过。
# vi /etc/sudoers
root ALL=(ALL) ALL
k8sadmin ALL=(ALL) ALL (添加本行)
确认可以执行执行 sudo
表示配置没问题。
2. 下载Docker离线安装包
二进制包,即可以直接使用的软件,无需再编译配置。但是需要选对平台,如X86 AIX等平台。
Docker官方Bin包下载地址
阿里云Docker镜像Bin包地址
这里选择正确的版本,选择18.09最新版本。
3. 准备Docker一些配置文件
创建一个目录,假设为: /home/k8sadmin/docker-install/
配置dasmon.json
在工作目录创建 daemon.josn,也可以直接配置/etc/docker/daemon.json文件,
{
"insecure-registries": [
"10.16.43.130:5080",
"registry.scrcu.com:80"
],
"registry-mirrors":[
"https://d8b3zdiw.mirror.aliyuncs.com"
],
"data-root": "/data/docker"
}
daemon.json指定用户运行docker参数,常用的还有一些:
insecure-registries: 不使用https的镜像仓库
graph: docker运行时文件存档路径\(v18.06之前的版本可以用,后面用data-root替换)
log-driver: 日志驱动
data-root: 新版本 替换graph的新参数(v18.09)
配置docker.service
可以从其他docker安装后的文件/usr/lib/systemd/system/docker.service
copy过来。 这里提供docker 18.09的范例,后续docker版本可能会变化:
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
#BindsTo=containerd.service. — 无需containerd。
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 -H unix://
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3
# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s
# 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
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this option.
TasksMax=infinity
# 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
[Install]
WantedBy=multi-user.target
好了到此你的文件夹应该有以下的文件列表:
# ls -1
daemon.json
docker-18.09.4.tgz
docker.service
4. 离线安装/配置Docker
创建Shell执行或者手动执行:
#:
echo " 1. unzip the docker bin."
tar zxvf docker-18.09.4.tgz
echo " 2. move docker* into /usr/bin "
cp docker/* /usr/bin/
#vi /etc/daemon.json
echo " 3. copy daemon.json, docker service into system "
mkdir /etc/docker
cp daemon.json /etc/docker/daemon.json
cp docker.service /usr/lib/systemd/system/docker.service
echo " 4. docker install successfully !, check docker info to see the result."
5. 启动验证
启动docker服务,设置开机启动服务。
systemctl daemon-reload
systemctl start docker
systemctl enable docker
#查看docker返回信息
docker info
#运行官方验证程序。
docker run hello-world
参考资料
远程下发:
scp -r docker_install k8sadmin@10.16.2.211:~
scp -r docker_install k8sadmin@10.16.2.212:~
scp -r docker_install k8sadmin@10.16.2.213:~
scp -r docker_install k8sadmin@10.16.2.214:~