centos 二进制安装docker
安装包下载地址:https://download.docker.com/linux/static/stable/x86_64/docker-20.10.9.tgz
脚本安装地址:https://www.cnblogs.com/leihongnu/p/16790906.html
1、解压到/usr/local
#tar -zxvf docker-20.10.9.tgz -C /usr/local
大部分的安装教程都是安装到/usr/bin下:cp docker/* /usr/bin,本次安装指定安装目录在/usr/local/docker下
2、编辑配置文件
# 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
#如果不是放在/usr/bin下,要指定环境变量到/usr/local/docker
Environment=PATH=/usr/local/docker:/usr/bin:/usr/sbin
ExecStart=/usr/local/docker/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
】
添加PATH环境变量
#echo “export PATH=$PATH:/usr/local/docker” >> /etc/profile
3、赋给docker.service文件添加执行权限
#chmod 755 /etc/systemd/system/docker.service
4、重新加载配置文件(每次有修改docker.service文件时都要重新加载下)
#systemctl daemon-reload
5、启动docker
#systemctl start docker
ps:修改docker文件存放路径
#查看存放路径
#docker info | grep "Docker Root Dir"
#修改路径到/data/docker/data
#vi /etc/docker/daemon.json
#添加指定新路径
{"data-root": "/data/docker/data"}
#重新加载
#systemctl daemon-reload
#重启docker
#systemctl restart docker
#查看是否修改成功
#docker info | grep "Docker Root Dir"