初始化设置

#设置主机名
hostnamectl set-hostname nodexxx
#关闭防火墙
systemctl status firewalld

#设置时区
timedatectl set-timezone Asia/Shanghai 
#使用阿里云同步时间
ntpdate ntp1.aliyun.com 


关闭 swap
swapoff -a && sudo sed -i 's/^.*swap/#&/g' /etc/fstab
或者 vi /etc/fstab,注释掉下面一行
/dev/mapper/xxxx swap ...
free -m #查看

关闭 selinux
#临时关闭
setenforce 0 
#永久关闭
sed -i 's/enforcing/disabled/' /etc/selinux/config
或者
vi /etc/sysconfig/selinux
SELINUX=disabled  # 修改以下参数,设置为disable
getenforce #查看

手动安装

apt-get install docker-ce docker-ce-cli containerd.io
#阿里源
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
#daocloud一键安装命令:(已失效)
curl -sSL https://get.daocloud.io/docker | sh
#清华源安装 https://mirror.tuna.tsinghua.edu.cn/help/docker-ce/
export DOWNLOAD_URL="https://mirrors.tuna.tsinghua.edu.cn/docker-ce"
curl -fsSL https://get.docker.com/ | sudo -E sh
#中科大源
http://mirrors.ustc.edu.cn/help/docker-ce.html

官网安装说明

#卸载所有冲突的包
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done

#设置源
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

#安装
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

阿里云

#安装命令如下
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
国内 daocloud 一键安装命令:
curl -sSL https://get.daocloud.io/docker | sh


#安装docker-compose 
文件名
docker-compose-Linux-x86_64
sudo curl -L "https://github.com/docker/compose/releases/download/v2.14.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
#国内加速
sudo curl -L "https://get.daocloud.io/docker/compose/releases/download/v2.12.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

sudo curl -L "https://github.com/docker/compose/releases/download/v2.6.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/v2.5.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/v2.3.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
v2.4.1
v2.5.1
v2.6.1
v2.7.0
v2.10.2
#设置权限
sudo chmod +x /usr/local/bin/docker-compose


下载太慢直接下载文件
sudo mv docker-compose-linux-x86_64_v2.3.4 /usr/local/bin/docker-compose
mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
改名为 /usr/local/bin/docker-compose (注docker-compose是文件名)

腾讯云

#官方脚本安装
curl -sSL https://get.docker.com/ | sh

/etc/docker/daemon.json
{
    "exec-opts": ["native.cgroupdriver=systemd"],
    "log-driver":"json-file",
    "log-opts": {"max-size":"10m", "max-file":"5"},
    "registry-mirrors": [
       "https://mirror.ccs.tencentyun.com"
    ]
}

cat <<EOL >/etc/docker/daemon.json
{
    "log-driver":"json-file",
    "log-opts": {"max-size":"5m", "max-file":"5"},
    "registry-mirrors": [
       "https://bhtknto5.mirror.aliyuncs.com"
    ]
}
EOL
cat /etc/docker/daemon.json
sudo systemctl daemon-reload
sudo systemctl restart docker

报错处理

查看 journalctl -xe 错误 
对应处理

删除各个组件,重装大部分错误都能解决