Docker安装-黄芮

Docker安装

1.连上终端后配置仓库

[root@localhost ~]# hostnamectl set-hostname hr
[root@localhost ~]# bash
[root@hr ~]# mount /dev/sr0 /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
[root@hr ~]# cd /etc/yum.repos.d
[root@hr yum.repos.d]# ls
redhat.repo
[root@hr yum.repos.d]# vim /etc/yum.repos.d/local.repo
[root@hr yum.repos.d]# cat /etc/yum.repos.d/local.repo

[AppStream]
name=AppStream
baseurl=file:///mnt/AppStream
enabled=1
gpgcheck=0

[BaseOS]
name=BaseOS
baseurl=file:///mnt/BaseOS
enabled=1
gpgcheck=0
[root@hr yum.repos.d]# 
[root@hr yum.repos.d]# dnf clean all
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

0 个文件已删除
[root@hr yum.repos.d]# dnf makecache
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

AppStream     59 MB/s | 6.5 MB     00:00    
BaseOS        42 MB/s | 2.0 MB     00:00    
上次元数据过期检查:0:00:02 前,执行于 2024年09月12日 星期四 20时28分53秒。
元数据缓存已建立。
[root@hr yum.repos.d]# 

2.阿里云网址developer.aliyun.com/mirror/docker-ce使用yum进行安装在这里插入图片描述

[root@hr yum.repos.d]# yum install -y yum-utils device-mapper-persistent-data lvm2
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

上次元数据过期检查:0:05:38 前,执行于 2024年09月12日 星期四 20时28分53秒。
软件包 device-mapper-persistent-data-1.0.6-3.el9_3.x86_64 已安装。
软件包 lvm2-9:2.03.21-3.el9.x86_64 已安装。
依赖关系解决。
=============================================
 软件包   架构   版本           仓库    大小
=============================================
安装:
 yum-utils
          noarch 4.3.0-11.el9_3 BaseOS  45 k

事务概要
=============================================
安装  1 软件包

总计:45 k
安装大小:23 k
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                              1/1 
  安装    : yum-utils-4.3.0-11.el9_3.n   1/1 
  运行脚本: yum-utils-4.3.0-11.el9_3.n   1/1 
  验证    : yum-utils-4.3.0-11.el9_3.n   1/1 
已更新安装的产品。

已安装:
  yum-utils-4.3.0-11.el9_3.noarch            

完毕!
[root@hr yum.repos.d]# 
[root@hr yum.repos.d]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

添加仓库自:https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@hr yum.repos.d]# 
[root@hr yum.repos.d]# sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
[root@hr yum.repos.d]# 
[root@hr yum.repos.d]# yum makecache fast
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

usage: yum makecache [-c [config file]]
                     [-q] [-v] [--version]
                     [--installroot [path]]
                     [--nodocs]
                     [--noplugins]
                     [--enableplugin [plugin]]
                     [--disableplugin [plugin]]
                     [--releasever RELEASEVER]
                     [--setopt SETOPTS]
                     [--skip-broken] [-h]
                     [--allowerasing]
                     [-b | --nobest] [-C]
                     [-R [minutes]]
                     [-d [debug level]]
                     [--debugsolver]
                     [--showduplicates]
                     [-e ERRORLEVEL]
                     [--obsoletes]
                     [--rpmverbosity [debug level name]]
                     [-y] [--assumeno]
                     [--enablerepo [repo]]
                     [--disablerepo [repo]
                     | --repo [repo]]
                     [--enable | --disable]
                     [-x [package]]
                     [--disableexcludes [repo]]
                     [--repofrompath [repo,path]]
                     [--noautoremove]
                     [--nogpgcheck]
                     [--color COLOR]
                     [--refresh] [-4] [-6]
                     [--destdir DESTDIR]
                     [--downloadonly]
                     [--comment COMMENT]
                     [--bugfix]
                     [--enhancement]
                     [--newpackage]
                     [--security]
                     [--advisory ADVISORY]
                     [--bz BUGZILLA]
                     [--cve CVES]
                     [--sec-severity {Critical,Important,Moderate,Low}]
                     [--forcearch ARCH]
                     [--timer]
yum makecache: error: argument timer: invalid choice: 'fast' (choose from 'timer')
[root@hr yum.repos.d]# 
[root@hr yum.repos.d]# yum -y install docker-ce
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

Docker CE St  94 kB/s |  56 kB     00:00    
依赖关系解决。
=============================================
 软件包     架构   版本
                      仓库              大小
=============================================
安装:
 docker-ce  x86_64 3:27.2.1-1.el9
                      docker-ce-stable  27 M
安装依赖关系:
 containerd.io
            x86_64 1.7.22-3.1.el9
                      docker-ce-stable  43 M
 docker-ce-cli
            x86_64 1:27.2.1-1.el9
                      docker-ce-stable 8.0 M
安装弱的依赖:
 docker-buildx-plugin
            x86_64 0.16.2-1.el9
                      docker-ce-stable  14 M
 docker-ce-rootless-extras
            x86_64 27.2.1-1.el9
                      docker-ce-stable 4.4 M
 docker-compose-plugin
            x86_64 2.29.2-1.el9
                      docker-ce-stable  13 M

事务概要
=============================================
安装  6 软件包

总下载:109 M
安装大小:426 M
下载软件包:
(1/6): docke 5.0 MB/s |  14 MB     00:02    
(2/6): docke 9.2 MB/s |  27 MB     00:02    
(3/6): conta  10 MB/s |  43 MB     00:04    
(4/6): docke 3.5 MB/s | 4.4 MB     00:01    
(5/6): docke 4.8 MB/s | 8.0 MB     00:01    
(6/6): docke  15 MB/s |  13 MB     00:00    
---------------------------------------------
总计          22 MB/s | 109 MB     00:05     
Docker CE St 8.6 kB/s | 1.6 kB     00:00    
导入 GPG 公钥 0x621E9F35:
 Userid: "Docker Release (CE rpm) <docker@docker.com>"
 指纹: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 来自: https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
导入公钥成功
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                              1/1 
  安装    : docker-compose-plugin-2.29   1/6 
  运行脚本: docker-compose-plugin-2.29   1/6 
  安装    : docker-buildx-plugin-0.16.   2/6 
  运行脚本: docker-buildx-plugin-0.16.   2/6 
  安装    : docker-ce-cli-1:27.2.1-1.e   3/6 
  运行脚本: docker-ce-cli-1:27.2.1-1.e   3/6 
  安装    : containerd.io-1.7.22-3.1.e   4/6 
  运行脚本: containerd.io-1.7.22-3.1.e   4/6 
  安装    : docker-ce-rootless-extras-   5/6 
  运行脚本: docker-ce-rootless-extras-   5/6 
  安装    : docker-ce-3:27.2.1-1.el9.x   6/6 
  运行脚本: docker-ce-3:27.2.1-1.el9.x   6/6 
  验证    : containerd.io-1.7.22-3.1.e   1/6 
  验证    : docker-buildx-plugin-0.16.   2/6 
  验证    : docker-ce-3:27.2.1-1.el9.x   3/6 
  验证    : docker-ce-cli-1:27.2.1-1.e   4/6 
  验证    : docker-ce-rootless-extras-   5/6 
  验证    : docker-compose-plugin-2.29   6/6 
已更新安装的产品。

已安装:
  containerd.io-1.7.22-3.1.el9.x86_64        
  docker-buildx-plugin-0.16.2-1.el9.x86_64   
  docker-ce-3:27.2.1-1.el9.x86_64            
  docker-ce-cli-1:27.2.1-1.el9.x86_64        
  docker-ce-rootless-extras-27.2.1-1.el9.x86_64
  docker-compose-plugin-2.29.2-1.el9.x86_64  

完毕!
[root@hr yum.repos.d]# 
[root@hr yum.repos.d]# cd
[root@hr ~]# systemctl status docker   ##开机即启动
○ docker.service - Docker Application Contai>
     Loaded: loaded (/usr/lib/systemd/system>
     Active: inactive (dead)
TriggeredBy: ○ docker.socket
       Docs: https://docs.docker.com
lines 1-5/5 (END)
[root@hr ~]# systemctl enable --now docker
[root@hr ~]# systemctl status docker  ##再次查看
○ docker.service - Docker Application Contai>
     Loaded: loaded (/usr/lib/systemd/system>
     Active: inactive (dead)
TriggeredBy: ○ docker.socket
       Docs: https://docs.docker.com
lines 1-5/5 (END)

Activate the web console with: systemctl enable --now cockpit.socket

Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last login: Thu Sep 12 20:21:39 2024 from 192.168.79.1
[root@hr ~]# systemctl enable --now docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[root@hr ~]# systemctl status docker
● docker.service - Docker Application Contai>
     Loaded: loaded (/usr/lib/systemd/system>
     Active: active (running) since Thu 2024>
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 34614 (dockerd)
      Tasks: 9
     Memory: 24.0M
        CPU: 740ms
     CGroup: /system.slice/docker.service
             └─34614 /usr/bin/dockerd -H fd:>

912 20:42:40 hr systemd[1]: Starting Dock>
912 20:42:40 hr dockerd[34614]: time="202>
9月 12 20:42:41 hr dockerd[34614]: time="202>
912 20:42:41 hr dockerd[34614]: time="202>
9月 12 20:42:45 hr dockerd[34614]: time="202>
912 20:42:46 hr dockerd[34614]: time="202>
9月 12 20:42:46 hr dockerd[34614]: time="202>
912 20:42:46 hr dockerd[34614]: time="202>
9月 12 20:42:46 hr dockerd[34614]: time="202>
lines 2-22/22 (END)

Activate the web console with: systemctl enable --now cockpit.socket

Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last login: Thu Sep 12 20:42:14 2024 from 192.168.79.1
[root@hr ~]# 

3.阿里云主页扫码登陆,点击控制台,搜索容器镜像服务,点击镜像加速器

[root@hr ~]# mkdir -p /etc/docker
[root@hr ~]# tee /etc/docker/daemon.json <<-'EOF'
> {
  "registry-mirrors": ["https://ax7omply.mirror.aliyuncs.com"]
}
> EOF
{
  "registry-mirrors": ["https://ax7omply.mirror.aliyuncs.com"]
}
[root@hr ~]# systemctl daemon-reload
[root@hr ~]# systemctl restart docker
[root@hr ~]# docker run hello-world
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值