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
相关推荐
DYWorker0017 分钟前
Linux驱动子系统:DMA-Buf —— Consumer和Provider(008)
linux·驱动开发
雯宝1 小时前
Linux 内核函数集
linux
GeW1 小时前
从挂科到高分通过:RHCE快速拿证的10个提分技巧
linux
我本善良ab2 小时前
PVE使用GRUB如何复位ubuntu的管理员密码?
ubuntu·忘记密码
鸠摩智首席音效师2 小时前
Linux /etc/nsswitch.conf 文件有什么作用 ?
linux
东城居士2 小时前
理解pinctrl和gpio子系统驱动
linux·嵌入式系统
H_oRIZoN_2 小时前
Linux入门DAY43 ARM 架构基础、寄存器、大小端、异常向量、交叉编译
linux·arm·linux应用编程
ι:3 小时前
NUC12 Pro 安装 Ubuntu 24.04 LTS 详细教程
linux·windows·ubuntu·nuc
代码村新手4 小时前
Linux-进程概念
linux
ShineWinsu4 小时前
对于Git:基础操作的超详细保姆级解析
linux·c++·git·面试·备份·管理·版本控制器