ubuntu22安装docker并配置镜像
安装docker
更新现有软件包索引:
安装必要的依赖包:
1
| sudo apt install apt-transport-https ca-certificates curl software-properties-common
|
添加docker官方的GPG密钥:
1
| curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
添加docker的apt仓库:
1
| echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
更新软件包索引:
安装docker:
1
| sudo apt install docker-ce docker-ce-cli containerd.io
|
查看是否安装成功:
启动并自启动docker:
1 2
| sudo systemctl start docker sudo systemctl enable docker
|
配置镜像源
修改/etc/docker/daemon.json
文件
1
| sudo vim /etc/docker/daemon.json
|
添加以下内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| { "registry-mirrors": ["https://docker.registry.cyou", "https://docker-cf.registry.cyou", "https://dockercf.jsdelivr.fyi", "https://docker.jsdelivr.fyi", "https://dockertest.jsdelivr.fyi", "https://mirror.aliyuncs.com", "https://dockerproxy.com", "https://mirror.baidubce.com", "https://docker.m.daocloud.io", "https://docker.nju.edu.cn", "https://docker.mirrors.sjtug.sjtu.edu.cn", "https://docker.mirrors.ustc.edu.cn", "https://mirror.iscas.ac.cn", "https://docker.rainbond.cc"] }
|
截至2024.12.11仍有效
验证是否能正常拉取image:
1
| sudo docker run hello-world
|