76 lines
2.7 KiB
Markdown
76 lines
2.7 KiB
Markdown
|
# Docker 配置镜像加速
|
|||
|
|
|||
|
## Docker-CE 安装配置加速
|
|||
|
- 加速站地址:https://gitee.com/sdlsgitee/open-source-mirror-sites/blob/master/%E5%9B%BD%E5%86%85%E5%BC%80%E6%BA%90%E9%95%9C%E5%83%8F%E7%AB%99%E7%82%B9%E9%9B%86%E5%90%88-2023%E5%B9%B42%E6%9C%8812%E6%97%A5%E5%8F%AF%E7%94%A8.md
|
|||
|
- 阿里云地址:https://developer.aliyun.com/mirror/?serviceType=&tag=&keyword=docker-ce
|
|||
|
```shell
|
|||
|
# Add Docker's official GPG key:
|
|||
|
sudo apt-get update
|
|||
|
sudo apt-get install ca-certificates curl
|
|||
|
sudo install -m 0755 -d /etc/apt/keyrings
|
|||
|
sudo curl -fsSL http://mirrors.163.com/docker-ce/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
|
|||
|
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
|||
|
|
|||
|
# Add the repository to Apt sources:
|
|||
|
echo \
|
|||
|
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
|
|||
|
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
|||
|
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|||
|
sudo apt-get update
|
|||
|
|
|||
|
|
|||
|
# step 1: 安装必要的一些系统工具
|
|||
|
sudo apt-get update
|
|||
|
sudo apt-get install ca-certificates curl gnupg
|
|||
|
|
|||
|
# step 2: 信任 Docker 的 GPG 公钥
|
|||
|
sudo install -m 0755 -d /etc/apt/keyrings
|
|||
|
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|||
|
sudo chmod a+r /etc/apt/keyrings/docker.gpg
|
|||
|
|
|||
|
# Step 3: 写入软件源信息
|
|||
|
echo \
|
|||
|
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
|
|||
|
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
|
|||
|
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|||
|
|
|||
|
# Step 4: 安装Docker
|
|||
|
sudo apt-get update
|
|||
|
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
|||
|
|
|||
|
# 安装指定版本的Docker-CE:
|
|||
|
# Step 1: 查找Docker-CE的版本:
|
|||
|
# apt-cache madison docker-ce
|
|||
|
# docker-ce | 17.03.1~ce-0~ubuntu-xenial | https://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
|
|||
|
# docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
|
|||
|
# Step 2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.1~ce-0~ubuntu-xenial)
|
|||
|
# sudo apt-get -y install docker-ce=[VERSION]
|
|||
|
```
|
|||
|
|
|||
|
## 添加加速镜像地址 `/etc/docker/daemon.json`
|
|||
|
```json
|
|||
|
{
|
|||
|
"registry-mirrors": [
|
|||
|
"https://docker.zhai.cm",
|
|||
|
"https://docker.fxxk.dedyn.io",
|
|||
|
"https://docker.5z5f.com",
|
|||
|
"https://a.ussh.net",
|
|||
|
"https://hub.geekery.cn/",
|
|||
|
"https://ghcr.geekery.cn",
|
|||
|
"https://registry.dockermirror.com"
|
|||
|
],
|
|||
|
"runtimes": {
|
|||
|
"nvidia": {
|
|||
|
"path": "nvidia-container-runtime",
|
|||
|
"runtimeArgs": []
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
```
|
|||
|
|
|||
|
## 重启 Docker
|
|||
|
```shell
|
|||
|
systemctl daemon-reload
|
|||
|
|
|||
|
systemctl restart docker
|
|||
|
```
|