Debian/Ubuntu 从软件源一键安装
安装 Docker
apt install -y docker.io docker-compose
自启动 Docker
systemctl enable --now docker
Docker 官方一键安装脚本
使用官方源安装(国内直接访问较慢):
curl -fsSL https://get.docker.com | bash
使用阿里源安装:
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
使用中国区 Azure 源安装:
curl -fsSL https://get.docker.com | bash -s docker --mirror AzureChinaCloud
设置开机自启:
systemctl enable docker
启动 Docker:
systemctl start docker
一键安装最新版 Docker Compose:
COMPOSE_VERSION=`git ls-remote https://github.com/docker/compose | grep refs/tags | grep -oP "[0-9]+\.[0-9][0-9]+\.[0-9]+$" | sort --version-sort | tail -n 1`
sh -c "curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose"
chmod +x /usr/local/bin/docker-compose
配置国内镜像源
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://0b27f0a81a00f3560fbdc00ddd2f99e0.mirror.swr.myhuaweicloud.com",
"https://ypzju6vq.mirror.aliyuncs.com",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
]
}
EOF
重启服务
systemctl daemon-reload
systemctl restart docker
正文完
发表至: 开源脚本
2023-11-18