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
相关推荐
探索云原生2 小时前
终于搞懂 Kueue:5 个核心对象一次讲透
linux·docker·ai·云原生·kubernetes
An_s3 小时前
机器学习python之识别图中物品信息
java·linux·开发语言
AI服务老曹3 小时前
Docker部署AI视频分析平台参数配置说明与调优指南
人工智能·docker·音视频
Championship.23.244 小时前
Linux 3.0 LVDS驱动开发详解
linux·运维·驱动开发·lvds
eggcode4 小时前
docker拉取、重命名、导出导入、删除镜像的示例
docker
风向决定发型丶4 小时前
Shell中的特殊变量
linux·运维·bash
mounter6255 小时前
走向长时运行:引入协程(Coroutines),打破 BPF 程序的“一堂到底”限制
linux·ebpf·kernel
运维大师5 小时前
【Linux运维极简教程】05-软件包管理
linux·运维·服务器
六点_dn6 小时前
Linux学习笔记-shell运算符
linux·笔记·学习
hehelm6 小时前
IO 多路复用 — Reactor
linux·服务器·网络·数据库·c++