ubuntu 22.04 安装docker-ce

发布时间 2023-09-04 17:08:43作者: 山有木兮yz
#!/bin/bash

##安装依赖
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
##安装GPG证书
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
##写入软件源信息
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
##更新并安装Docker-CE
sudo apt-get -y update
sudo apt-get -y install docker-ce
#启动docker
systemctl start docker && systemctl enable docker
#添加阿里云镜像加速
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://pngamxmy.mirror.aliyuncs.com"],
  "live-restore": true,
  "log-driver": "json-file",
  "log-opts": {
   "max-file": "3",
   "max-size": "100m"
 }
}
EOF
##重新加载配置和重启docker
systemctl daemon-reload && systemctl restart docker
##软连接docker-compose
ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/local/bin/docker-compose
##版本信息
docker-compose --version