安装 Docker-yum-阿里云镜像

Architecture: x86-64

Operating System: Alibaba Cloud Linux 3 (Soaring Falcon)

Docker Engine - Community 26.0.0

---

 

序章

官方文档:Install Docker Engine on CentOS

https://docs.docker.com/engine/install/centos/

注,Alibaba Cloud Linux 3 是一个 CentOS 系统。

 

阿里云 Docker CE 镜像

https://developer.aliyun.com/mirror/docker-ce

 

说明,

根据官网文档 也可以安装,但考虑到 下载速度,最后选择了 阿里云镜像 进行安装。

说明,

安装全程使用 root 账号。

 

安装步骤

打开 阿里云 Docker CE 镜像 页面:

因为 Alibaba Cloud Linux 3 是一个 CentOS 系统,选择 配置方法中的【CentOS 7(使用 yum 进行安装)】:

阿里云镜像 的 CentOS 7 完整命令:

# step 1: 安装必要的一些系统工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加软件源信息
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3
sudo sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
# Step 4: 更新并安装Docker-CE
sudo yum makecache fast
sudo yum -y install docker-ce
# Step 4: 开启Docker服务
sudo service docker start

 

准备

Alibaba Cloud Linux 3 已安装 yum-utils 等,故,省略第一步。

执行 第二步:

# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

此时,/etc/yum.repos.d 目录下出现一个 docker-ce.repo 文件。

顺利。

执行 第三步:

# sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo

顺利。

 

执行 第四步:

# yum makecache fast

出现错误:

yum makecache: error: argument timer: invalid choice: 'fast' (choose from 'timer')

更加 参考文档#1 解决:Alibaba Cloud Linux 3 是 CentOS 8,而不是 CentOS 7。

换为 执行下面的命令:

# dnf makecache

顺利。

 

yum 查找 docker:

可以看到 已经有 docker-ce、docker-ce-cli 两个包了。

 

yum 查看 docker-ce 的信息:

# yum info docker-ce
Last metadata expiration check: 0:01:27 ago on Wed 27 Mar 2024 11:16:53 AM CST.
Available Packages
Name         : docker-ce
Epoch        : 3
Version      : 26.0.0
Release      : 1.el8
Architecture : x86_64
Size         : 27 M
Source       : docker-ce-26.0.0-1.el8.src.rpm
Repository   : docker-ce-stable
Summary      : The open-source application container engine
URL          : https://www.docker.com
License      : ASL 2.0
Description  : Docker is a product for you to build, ship and run any application as a
             : lightweight container.
             :
             : Docker containers are both hardware-agnostic and platform-agnostic. This means
             : they can run anywhere, from your laptop to the largest cloud compute instance
             : and everything in between - and they don't require you to use a particular
             : language, framework or packaging system. That makes them great building blocks
             : for deploying and scaling web apps, databases, and backend services without
             : depending on a particular stack or provider.

 

安装

执行 第五步:安装

# yum -y install docker-ce
Last metadata expiration check: 0:04:10 ago on Wed 27 Mar 2024 11:16:53 AM CST.
Dependencies resolved.

省略

Install  12 Packages

省略

Installed:
  containerd.io-1.6.28-3.2.el8.x86_64                 docker-buildx-plugin-0.13.1-1.el8.x86_64        docker-ce-3:26.0.0-1.el8.x86_64            docker-ce-cli-1:26.0.0-1.el8.x86_64
  docker-ce-rootless-extras-26.0.0-1.el8.x86_64       docker-compose-plugin-2.25.0-1.el8.x86_64       fuse-overlayfs-1.11-1.0.1.al8.x86_64       fuse3-3.3.0-16.al8.x86_64
  fuse3-libs-3.3.0-16.al8.x86_64                      libcgroup-0.41-19.2.al8.x86_64                  libslirp-4.4.0-1.al8.x86_64                slirp4netns-1.2.0-2.al8.x86_64

Complete!

顺利。

 

启动

执行 第六步:查看 Docker (服务器) 运行状态,并启动。

# systemctl status docker # 查看状态

# systemctl start docker # 启动

启动后的状态显示为 active (running)

默认 开机启动。

ben发布于博客园

查看 docker 服务的进程信息:

# ps -ef | grep docker
root      302148       1  0 11:22 ?        00:00:10 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

查看其它信息:

# whereis docker
docker: /usr/bin/docker /etc/docker /usr/libexec/docker /usr/share/man/man1/docker.1.gz

# whereis dockerd
dockerd: /usr/bin/dockerd /usr/share/man/man8/dockerd.8.gz

# ls /usr/bin | grep docker
docker
dockerd
dockerd-rootless-setuptool.sh
dockerd-rootless.sh
docker-proxy
rootlesskit-docker-proxy

ben发布于博客园

检查配置:/etc/docker 目录

此时,目录下什么也没有。

# cd /etc/docker/
[root@--- docker]# pwd
/etc/docker
[root@--- docker]# ll
total 0

ben发布于博客园

查看安装的 docker 版本:Server, Client 都是 26.0.0。

# docker version
Client: Docker Engine - Community
 Version:           26.0.0
 API version:       1.45
 Go version:        go1.21.8
 Git commit:        2ae903e
 Built:             Wed Mar 20 15:19:04 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          26.0.0
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.8
  Git commit:       8b79278
  Built:            Wed Mar 20 15:17:57 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

ben发布于博客园

验证:运行 hello-world 镜像

执行 下面的命令:

# docker run hello-world

本地没有,先拉取,拉取后,运行。

截图:

顺利。验证通过。

 

使用 docker images 命令,可以看到拉取了一个名为 hello-world 的镜像。

# docker images
REPOSITORY       TAG       IMAGE ID       CREATED         SIZE
hello-world      latest    d2c94e258dcb   10 months ago   13.3kB

 

至此,安装完毕。

ben发布于博客园

本文涉及命令

  1. yum-config-manager --add-repo ...
  2. sed -i ...
  3. yum makecache fast
  4. dnf makecache
  5. yum search docker
  6. yum info docker-ce
  7. yum -y install docker-ce
  8. systemctl status docker
  9. systemctl start docker
  10. docker version
  11. docker run hello-world
  12. docker images

 

说明,

dnf 就是 yum,新版本的 yum。

# man yum

 

说明,

sed 命令,sed - stream editor for filtering and transforming text。

# man sed

-i 选项:

-i[SUFFIX], --in-place[=SUFFIX]

              edit files in place (makes backup if SUFFIX supplied)

菜鸟教程:

语法 sed [-hnV][-e<script>][-f<script文件>][文本文件]

  • i :插入, i 的后面可以接字串,而这些字串会在新的一行出现(目前的上一行);

 

ben发布于博客园

---END---

 

本文链接:

https://www.cnblogs.com/luo630/p/18099590

ben发布于博客园

参考资料

1、Linux - Centos 8 执行 yum makecache fast 报错

2022-05-15

https://developer.aliyun.com/article/921972

2、菜鸟教程:Docker 教程

https://www.runoob.com/docker/docker-tutorial.html

可以学习 其它 docker 命令的基本操作,Dockerfile 的制作;

可以配置自己的 docker hub 地址,比如,阿里云的;

3、菜鸟教程:Linux sed 命令

https://www.runoob.com/linux/linux-comm-sed.html

4、

 

ben发布于博客园

ben发布于博客园

 

posted @ 2024-03-27 22:09  快乐的凡人721  阅读(86)  评论(0编辑  收藏  举报