Ubuntu安装Docker详细版教程
1.首先打开终端,更新所有软件
sudo apt update
2. 安装依赖包【用于通过HTTPS来获取仓库】
sudo apt install apt-transport-https ca-certificates
sudo apt install software-properties-common
3. 添加Docker官方GPG密钥
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/docker-ce.gpg
4. 验证密钥
sudo apt-key fingerprint 0EBFCD88
5. 添加Docker阿里稳定版软件源
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
6. 再次更新软件包
sudo apt update
7. 安装默认最新版
sudo apt install docker-ce docker-ce-cli containerd.io
8. 安装好后启动
sudo docker run hello-world
如果输出“Hello from Docker!”则表示Docker已经成功安装。
9. 报错情况
解决方法编辑配置文件::
sudo vim /etc/docker/daemon.json
将下列配置写进去
{
"dns": ["8.8.8.8", "8.8.4.4"],
"registry-mirrors": [
"https://docker.m.daocloud.io/",
"https://huecker.io/",
"https://dockerhub.timeweb.cloud",
"https://noohub.ru/",
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn",
"https://xx4bwyg2.mirror.aliyuncs.com",
"http://f1361db2.m.daocloud.io",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com"
],
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
}
}
10. 重新加载
sudo systemctl daemon-reload
11. 重启Docker服务
sudo systemctl restart docker
12. 再次使用服务
sudo docker run hello-world
13. 查看相关信息
root@zzyzzye-virtual-machine:~# docker -v
Docker version 28.3.2, build 578ccf6
root@zzyzzye-virtual-machine:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 74cc54e27dc4 5 months ago 10.1kB
评论区