ubuntu上修改docker的镜像源
时间: 2024-11-01 18:06:29 浏览: 42
在Ubuntu上修改Docker的镜像源通常是为了从非官方或更快的镜像仓库下载更新更快的镜像。以下是步骤:
1. **切换到阿里云的Docker Hub源** (如果尚未添加):
- 打开终端 (`Ctrl + Alt + T` 或者 `Alt + F2` 然后输入 `termina`)
- 运行以下命令替换原有的源:
```
sudo apt-get update && \
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common && \
curl -fsSL https://mirrors.aliyun.com/docker-ce/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
```
2. **刷新并安装Docker**:
```
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
```
3. **启动并验证Docker是否使用新设置的源**:
```
sudo systemctl start docker
sudo systemctl enable docker
docker run hello-world
```
阅读全文