跳转至

Rocky 安装 Docker

环境

  • OS : Rocky 9 / CentOS 9 / RHEL 9
  • User : root

1 卸载老版本

只卸载软件,Images、containers、volumes 和 networks (默认存在 /var/lib/docker/) 不会删除。

dnf remove docker \
           docker-client \
           docker-client-latest \
           docker-common \
           docker-latest \
           docker-latest-logrotate \
           docker-logrotate \
           docker-engine

2 设置仓库

dnf -y install dnf-plugins-core
dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sed -i 's+https://download.docker.com+https://mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo

3 安装

安装的同时创建了一个docker用户组,但是并没有添加用户到该用户组。

3.1 在线安装

  • 安装最新版本

    dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    

  • 安装指定版本

1 查询可用版本

dnf list docker-ce --showduplicates | sort -r
查询可用docker版本

2 安装指定版本 比如要安装 docker-ce-3:28.1.1-1.el9,那么 VERSION_STRING=3:28.1.1-1.el9

dnf install docker-ce-VERSION_STRING docker-ce-cli-VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin

3.2 离线安装

4 启动docker

systemctl enable --now docker

文档来源于官网。

本文阅读量  次    本站总访问量  次