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

自启动Docker

systemctl enable --now 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/v${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://dockerproxy.com",
    "https://docker.m.daocloud.io",
    "https://ypzju6vq.mirror.aliyuncs.com"
  ]
}
EOF
systemctl daemon-reload
systemctl restart docker