Ubuntu 安装docker

1: 卸载旧版本

如果你曾经安装过旧版本的 Docker,首先需要卸载它们:

bash 复制代码
sudo apt-get remove docker docker-engine docker.io containerd runc

2: 安装依赖工具

安装一些必要的工具,以便后续的安装过程能够顺利进行:

bash 复制代码
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

3: 添加 Docker 官方 GPG 密钥

bash 复制代码
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

4: 设置稳定的 Docker 存储库

bash 复制代码
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

5: 安装 Docker Engine

bash 复制代码
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

6: 验证 Docker 安装

bash 复制代码
sudo docker --version

7: 将用户添加到 Docker 用户组(可选)

为了让你的用户不需要使用 sudo 权限就能够运行 Docker 命令,你可以将其添加到 Docker 用户组中:

bash 复制代码
sudo usermod -aG docker your_username

8: 重启并测试 Docker

bash 复制代码
sudo systemctl restart docker
docker run hello-world
相关推荐
程序员老赵14 小时前
10 分钟部署 OpenCode:Docker 一键安装,浏览器打开就能用 AI 写代码(附完整命令与排错)
docker·容器·ai编程
WangMingHua11118 小时前
LM Studio Docker 部署——本地大模型一键启动
docker
Sokach10151 天前
Linux Shell 脚本从零到能用:一个新手的一天学习总结
linux
AlfredZhao2 天前
Docker 容器时区不对,`timedatectl` 不存在怎么办?
linux·timezone
曲幽2 天前
别再用网页翻译看源码了!你的私人翻译神器LibreTranslate,部署避坑指南来了
python·docker·web·pot·translate·libretranslate·arogstranslate
zzzzzz3103 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode3 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
武子康4 天前
调查研究-183 Apple container:Mac 上用轻量 VM 跑 Linux 容器,Swift 会改写本地容器体验吗?
docker·容器·apple
A小辣椒5 天前
TShark:Wireshark CLI 功能
linux
A小辣椒5 天前
TShark:基础知识
linux