#!/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
标签:get,##,sudo,apt,22.04,ce,docker
From: https://www.cnblogs.com/wxq-yz/p/17677577.html