Ubuntu20.04操作系统安装Docker

1、添加Docker仓库

curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

 sudo add-apt-repository \
   "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \
  $(lsb_release -cs) \
  stable"

2、安装Docker

sudo apt-get install docker-ce docker-ce-cli containerd.io -y

3、添加配置Docker镜像

cat <<EOF | tee /etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "registry-mirrors": ["https://aoewjvel.mirror.aliyuncs.com"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF

4、启动Docker && 加入开机自启动

mkdir -p /etc/systemd/system/docker.service.d
systemctl daemon-reload
systemctl restart docker
systemctl enable --now docker
systemctl status docker

猜你喜欢

转载自blog.csdn.net/weixin_45310323/article/details/132125073