安装Java环境

mkdir -p /etc/jdk
mkdir /download
cd /download/
tar -xzvf server-jre-8u341-linux-x64.tar.gz -C /etc/jdk/
​
vim /etc/profile
​
export JAVA_HOME=/etc/jdk/jdk1.8.0_341
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
​
source /etc/profile

安装Docker

yum install -y yum-utils
​
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
​
yum install -y docker-ce
​
systemctl start docker
​
systemctl enable docker
​
docker load < centos_jdk.tar
​
# 更新镜像源缓存
dnf makecache
# 修改chrony时间同步配置
sed -i 's/pool pool.ntp.org iburst/pool ntp.aliyun.com/g' /etc/chrony.conf
# 重启chrony服务
systemctl restart chronyd
# 查看NTP服务器是否在线
chronyc sources
​
​
# 创建docker配置目录
mkdir /etc/docker
# 创建配置文件
tee /etc/docker/daemon.json <<-'EOF'
{
  "debug": true,
  "storage-driver": "overlay2",
  "storage-opts":["overlay2.override_kernel_check=true"],
  "graph":"/opt/docker",
  "registry-mirrors": [
  "https://hub-mirror.c.163.com",
  "https://docker.mirrors.ustc.edu.cn",
  "https://registry.docker-cn.com"
  ]
}
EOF
# 使用镜像源安装docker
dnf install docker
# 启动docker
systemctl start docker
# 开启docker开机自动启动
systemctl enable docker
# 查看docker版本信息
docker info

无网络安装

如果要修改/etc/docker/daemon.json文件, 例如镜像源(主机没网络修改了也没用)或私有仓库(需和主机在同一局域网,不然也没用)
则先修改后再安装
tar xzvf docker-20.10.5.tgz -C /usr/bin/
sudo cp docker/* /usr/bin/

## 如果失败:
删除/var/run/docer文件夹
删除/var/lib/docker文件夹
删除/var/run/docker.pid文件
删除/var/run/docker.sock文件
ps -aux | grep docker
停止docker相关进程
netstat -nplt | grep docker
解除docker相关进程占用端口
重新执行上述步骤

vim /etc/systemd/system/docker.service

chmod +x /etc/systemd/system/docker.service

systemctl daemon-reload
systemctl start docker			#启动Docker
systemctl enable docker.service			#设置开机自启

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