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
相关推荐
wei20233 分钟前
Ubuntu24.04 搜狗输入法 闪烁无法输入问题解决
ubuntu·搜索引擎
旖旎夜光18 分钟前
Linux(3)(上)
linux·学习
❀͜͡傀儡师40 分钟前
Docker安装SQL Server并使用Navicat远程连接
运维·docker·容器
zhuzewennamoamtf1 小时前
Linux Regmap API寄存器映射抽象化
linux·运维·服务器
Joker 0071 小时前
Linux nohup命令实战指南
linux·运维·wpf
大聪明-PLUS1 小时前
管理 Linux 内核模块
linux·嵌入式·arm·smarc
lifewange1 小时前
关于进程的 Linux 命令有哪些?
linux·运维·服务器
三两肉1 小时前
Linux 网络包的 “快递分拣”:从发送到接收的内核协作全景
linux·网络·计算机网络·tcp
Chirnyo1 小时前
Ubuntu20.04.6安装RTXPRO6000驱动
运维·ubuntu
Maguyusi2 小时前
pve lxc 虚拟机 raw 格式 磁盘 扩容
linux·运维·windows