Linux 一键安装 docker 脚本
Install
https://docs.docker.com/engine/install/debian/
curl -s https://get.docker.com/ | sudo sh
# or
curl -fsSL https://get.docker.com | sudo bash -s docker --mirror Aliyun
华为云镜像
https://repo.huaweicloud.com/docker-ce/
https://mirrors.huaweicloud.com/
sudo apt-get remove docker docker-engine docker.io
sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://repo.huaweicloud.com/docker-ce/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://repo.huaweicloud.com/docker-ce/linux/debian $(lsb_release -cs) stable"
注意:
不在官方支持的操作系统时,需要将上述的 $(lsb_release -cs)
改为 /docker-ce/linux/debian/dists/
下列表的名称之一,比如 bookworm
deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable
北外镜像(推荐)
(同步比较不及时)
https://mirrors.bfsu.edu.cn/help/docker-ce/
export DOWNLOAD_URL="https://mirrors.bfsu.edu.cn/docker-ce"
# 如您使用 curl
curl -fsSL https://get.docker.com/ | sh
# 如您使用 wget
wget -O- https://get.docker.com/ | sh
# 或者集合在一起使用
DOWNLOAD_URL="https://mirrors.bfsu.edu.cn/docker-ce" wget -O- https://get.docker.com/ | sh
DOWNLOAD_URL="https://mirrors.bfsu.edu.cn/docker-ce" curl -fsSL https://get.docker.com/ | sh
---
# curl -fsSL https://mirrors.bfsu.edu.cn/docker-ce/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.bfsu.edu.cn/docker-ce/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Rootless
文档:https://docs.docker.com/engine/security/rootless/
dockerd-rootless-setuptool.sh install
# or
curl -fsSL https://get.docker.com/rootless | sh
守护进程
sudo loginctl enable-linger $(whoami)
镜像站
# 上海交大
https://docker.mirrors.sjtug.sjtu.edu.cn/
# 腾讯
https://mirror.ccs.tencentyun.com/
# DaoCloud
http://f1361db2.m.daocloud.io
# 华为
https://05f073ad3c0010ea0f4bc00b7105ec20.mirror.swr.myhuaweicloud.com
# 网易
http://hub-mirror.c.163.com
```bash
{
"registry-mirrors": ["https://05f073ad3c0010ea0f4bc00b7105ec20.mirror.swr.myhuaweicloud.com","https://mirror.ccs.tencentyun.com","http://f1361db2.m.daocloud.io", "http://hub-mirror.c.163.com"]
}
Root
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["http://hub-mirror.c.163.com/", "https://registry.docker-cn.com/"]
}
EOF
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://mirror.ccs.tencentyun.com/"]
}
EOF
# 不支持 systemd 的旧系统
echo 'DOCKER_OPTS="--registry-mirror=https://mirror.ccs.tencentyun.com"' > /etc/default/docker
sudo systemctl daemon-reload
sudo systemctl restart docker
Rootless
mkdir -p ~/.config/docker
tee ~/.config/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["http://hub-mirror.c.163.com/", "https://registry.docker-cn.com/"]
}
EOF
systemctl --user restart docker
使用 docker info
查看设置