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
相关推荐
Mortalbreeze15 小时前
深度理解进程----进程状态
linux·运维·服务器
艾莉丝努力练剑15 小时前
【Linux网络】Linux 网络编程入门:TCP Socket 编程(下)
linux·运维·服务器·网络·c++·tcp/ip
宵时待雨15 小时前
linux笔记归纳4:进程概念
linux·运维·服务器·c++·笔记
零K沁雪15 小时前
OpenV_X_N 2.5.x 配置文件选项详解
linux
原来是猿15 小时前
TCP Echo Server 深度解析:从单进程到线程池的演进之路(中)
linux·服务器·数据库
leoZ23115 小时前
Linux 环境常用服务一键部署文档(Docker 版)
运维·docker·容器
追寻少年15 小时前
基于Kubeadm和Docker部署K8S高可用集群
docker·容器·kubernetes
fTiN CAPA16 小时前
Linux系统离线部署MySQL详细教程(带每步骤图文教程)
linux·mysql·adb
GitCode官方16 小时前
投稿|Git + Docker 零基础入门攻略
git·docker·容器
xlq2232216 小时前
52.TcpSocket
linux·服务器·网络