更换源
第一步、查看一下源列表
less /etc/apt/sources.list
第二步、备份一下源列表
cp /etc/apt/sources.list /etc/apt/sources.list.bak
第三步、编辑源列表文件
编辑文件
vi /etc/apt/sources.list
删除里面所有内容(上面有备份)
阿里云镜像内容如下
deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
退出保存
安装Docker并配置
第一步、安装必要的一些系统工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
第二步、安装GPG证书
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo apt-key add -
第三步、写入软件源信息
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/debian $(lsb_release -cs) stable"
第四步、更新并安装Docker-CE
sudo apt-get -y update
sudo apt-get -y install docker-ce
sudo apt-get -y install docker-ce
如果是root就不用sudo了
第五步、启用Docker
systemctl start docker
或者
service docker start
安装指定版本的Docker-CE:
①: 查找Docker-CE的版本:
apt-cache madison docker-ce
docker-ce | 17.03.1~ce-0~ubuntu-xenial | https://mirrors.aliyun.com/docker-ce/linux/debian xenial/stable amd64 Packages
docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://mirrors.aliyun.com/docker-ce/linux/debian xenial/stable amd64 Packages
②: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.1~ce-0~debian-xenial)
sudo apt-get -y install docker-ce=[VERSION]