準(zhǔn)備安裝runtime -Docker
- 更新apt包索引并安裝包以允許apt通過HTTPS使用存儲(chǔ)庫
apt update -y
sudo apt-get -y install ca-certificates curl gnupg-agent lsb-release - 添加Docker的官方GPG密鑰
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg - 添加Docker的存儲(chǔ)庫
echo "deb [arch=(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null - 安裝Docker engine
sudo apt-get -y update
apt-get install docker-ce docker-ce-cli containerd.io -y - 配置 Docker 守護(hù)程序貌夕,尤其是使用 systemd 來管理容器的 cgroup
sudo mkdir /etc/docker
cat <<EOF | sudo tee /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
systemctl daemon-reload
systemctl restart docker
systemctl enable docker - docker0 網(wǎng)橋的容器添加了ACCEPT規(guī)則
sed -i '18c ExecStartPost=/sbin/iptables -P FORWARD ACCEPT' /lib/systemd/system/docker.service
systemctl daemon-reload && systemctl restart docker.service