Ubuntu22.04安装docker教程

1. 使用命令查看Ubuntu版本

cpp 复制代码
lsb_release -a

2. 安装docker

2.1 安装所需要的系统工具

cpp 复制代码
sudo apt-get update

2.2 添加 Docker 的官方 GPG 密钥

依次执行以下命令

cpp 复制代码
sudo apt-get install ca-certificates curl
cpp 复制代码
sudo install -m 0755 -d /etc/apt/keyrings
cpp 复制代码
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
cpp 复制代码
sudo chmod a+r /etc/apt/keyrings/docker.asc

2.3 将存储库添加到 Apt 源

cpp 复制代码
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
cpp 复制代码
sudo apt-get update

2.4 安装最新版本的Docker

此步骤有点耗时,耐心等待~

cpp 复制代码
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

2.5 拉取hello-world镜像

使用命令查看docker是否安装成功

bash 复制代码
docker --version

显示docker已经安装成功,但是我们拉取镜像的时候,会遇到问题,使用docker version查看的时候,发现docker服务器没有启动。

也可以使用service docker start命令来启动服务器

注意:正常情况下,使用下面命令可正常拉取镜像成功,则表示docker可用。

cpp 复制代码
sudo docker pull hello-world

sudo docker run hello-world

在此处拉取镜像时,遇到以下问题

通过以下配置加速器地址可解决问题

2.6 配置加速器地址

cpp 复制代码
sudo mkdir -p /etc/docker
cpp 复制代码
sudo tee /etc/docker/daemon.json <<-'EOF'
{
    "registry-mirrors": [
        "https://do.nark.eu.org",
        "https://dc.j8.work",
        "https://docker.m.daocloud.io",
        "https://dockerproxy.com",
        "https://docker.mirrors.ustc.edu.cn",
        "https://docker.nju.edu.cn"
    ]
}
EOF
cpp 复制代码
sudo systemctl daemon-reload

sudo systemctl restart docker

输入命令,拉取hello-world镜像

有问题可在评论区展开讨论~

相关推荐
SelectDB19 小时前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
AlfredZhao20 小时前
Docker 容器时区不对,`timedatectl` 不存在怎么办?
linux·timezone
曲幽1 天前
别再用网页翻译看源码了!你的私人翻译神器LibreTranslate,部署避坑指南来了
python·docker·web·pot·translate·libretranslate·arogstranslate
zzzzzz3102 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode2 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
用户0328472220703 天前
如何搭建本地yum源(上)
运维
武子康3 天前
调查研究-183 Apple container:Mac 上用轻量 VM 跑 Linux 容器,Swift 会改写本地容器体验吗?
docker·容器·apple
A小辣椒4 天前
TShark:Wireshark CLI 功能
linux
A小辣椒4 天前
TShark:基础知识
linux
AlfredZhao4 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci