docker的安装

▶ docker的安装

▷ rhel系配置源

对于一些常见的发行版本如:Ubuntu、arch 等配置源不是那么重要,但是对于RHEL的相关系统就比较重要了。

由于目前的RHEL已经不在提供docker的相关软件包,所有这就需要去配置第三方的软件源。

在阿里源中可以找到docker相关的包:

https://developer.aliyun.com/mirror/docker-ce?spm=a2c6h.13651102.0.0.57e31b11DxjcZK

官网的 repo 文件:

https://download.docker.com/linux/centos/docker-ce.repo

阿里的 repo 文件:

https://mirrors.aliyun.com/docker-ce/linux/rhel/docker-ce.repo

这里使用阿里的源来构建docker的源:

[root@server ~]# wget -O /etc/yum.repos.d/docker.repo https://mirrors.aliyun.com/docker-ce/linux/rhel/docker-ce.repo
[root@server ~]# dnf makecache
Docker CE Stable - x86_64          11 kB/s | 3.5 kB     00:00
--snip--

这样就有了 Docker CE Stable 的源。

▷ 安装 docker

[root@server ~]# dnf install device-mapper-persistent-data -y
[root@server ~]# dnf install lvm2
[root@server ~]# yum install docker-ce -y
[root@server ~]# yum install docker-ce-cli -y
[root@server ~]# yum install containerd.io -y

docker-ce:是Docker的社区版。它是一个完整的容器化平台,包括了Docker-ce-cli以及其他必要的组件,如Docker守护程序和基础设施管理工具。Docker-ce 提供了构建、发布和运行容器化应用所需的一切,使开发者能够更加高效地管理和部署应用程序。

docker-ce-cli:Docker的命令行客户端工具(Command Line Interface)。它允许用户通过命令行界面与Docker守护程序进行交互,从而管理容器和镜像。

containerd.io:一个面向容器运行时的基本组件。它充当了Docker引擎的核心,负责管理容器的生命周期、镜像管理和存储。


[root@server ~]# systemctl start docker

▶ 测试-使用 docker 拉取一个镜像

由于运营商网络原因,会导致拉取Docker Hub镜像变慢,甚至下载失败,这就需要通过 镜像加速器 来解决。
配置网址 https://help.aliyun.com/zh/acr/user-guide/accelerate-the-pulls-of-docker-official-images

拉取镜像测试:
拉取的是 hello-world 镜像

[root@server ~]# docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
posted @ 2024-09-06 15:21  takenika  阅读(27)  评论(0)    收藏  举报