DOCKER第一天

如有错误,敬请谅解!

此文章仅为本人学习笔记,仅供参考,如有冒犯,请联系作者删除!!!

1、安装docker-ce

# docker --version
# docker version
# docker run hello-world
# docker run -it ubuntu bash

2、下载并查看镜像

下载nginx的镜像,alpine的镜像,httpd的镜像并且给httpd镜像重新打标签为test/httpd:v1

以CentOS 7.4为例

1、安装docker-ce

    添加 docker-ce 源信息
[root@localhost ~]# yum install yum-utils device-mapper-persistent-data lvm2 -y

已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
软件包 yum-utils-1.1.31-54.el7_8.noarch 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 device-mapper-persistent-data.x86_64.0.0.7.0-0.1.rc6.el7 将被 升级
---> 软件包 device-mapper-persistent-data.x86_64.0.0.8.5-3.el7_9.2 将被 更新
---> 软件包 lvm2.x86_64.7.2.02.171-8.el7 将被 升级
---> 软件包 lvm2.x86_64.7.2.02.187-6.el7_9.5 将被 更新
--> 正在处理依赖关系 lvm2-libs = 7:2.02.187-6.el7_9.5,它被软件包 7:lvm2-2.02.187-6.el7_9.5.x86_64 需要
--> 正在处理依赖关系 libdevmapper.so.1.02(DM_1_02_141)(64bit),它被软件包 7:lvm2-2.02.187-6.el7_9.5.x86_64 需要
--> 正在检查事务
---> 软件包 device-mapper-libs.x86_64.7.1.02.140-8.el7 将被 升级
--> 正在处理依赖关系 device-mapper-libs = 7:1.02.140-8.el7,它被软件包 7:device-mapper-1.02.140-8.el7.x86_64 需要
---> 软件包 device-mapper-libs.x86_64.7.1.02.170-6.el7_9.5 将被 更新
---> 软件包 lvm2-libs.x86_64.7.2.02.171-8.el7 将被 升级
---> 软件包 lvm2-libs.x86_64.7.2.02.187-6.el7_9.5 将被 更新
--> 正在处理依赖关系 device-mapper-event = 7:1.02.170-6.el7_9.5,它被软件包 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64 需要
--> 正在检查事务
---> 软件包 device-mapper.x86_64.7.1.02.140-8.el7 将被 升级
---> 软件包 device-mapper.x86_64.7.1.02.170-6.el7_9.5 将被 更新
---> 软件包 device-mapper-event.x86_64.7.1.02.140-8.el7 将被 升级
---> 软件包 device-mapper-event.x86_64.7.1.02.170-6.el7_9.5 将被 更新
--> 正在处理依赖关系 device-mapper-event-libs = 7:1.02.170-6.el7_9.5,它被软件包 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64 需要
--> 正在检查事务
---> 软件包 device-mapper-event-libs.x86_64.7.1.02.140-8.el7 将被 升级
---> 软件包 device-mapper-event-libs.x86_64.7.1.02.170-6.el7_9.5 将被 更新
--> 解决依赖关系完成

依赖关系解决

==========================================================================================================
 Package                               架构           版本                          源               大小
==========================================================================================================
正在更新:
 device-mapper-persistent-data         x86_64         0.8.5-3.el7_9.2               updates         423 k
 lvm2                                  x86_64         7:2.02.187-6.el7_9.5          updates         1.3 M
为依赖而更新:
 device-mapper                         x86_64         7:1.02.170-6.el7_9.5          updates         297 k
 device-mapper-event                   x86_64         7:1.02.170-6.el7_9.5          updates         192 k
 device-mapper-event-libs              x86_64         7:1.02.170-6.el7_9.5          updates         192 k
 device-mapper-libs                    x86_64         7:1.02.170-6.el7_9.5          updates         325 k
 lvm2-libs                             x86_64         7:2.02.187-6.el7_9.5          updates         1.1 M

事务概要
==========================================================================================================
升级  2 软件包 (+5 依赖软件包)

总计:3.8 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在更新    : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64                                       1/14 
  正在更新    : 7:device-mapper-1.02.170-6.el7_9.5.x86_64                                            2/14 
  正在更新    : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64                                 3/14 
  正在更新    : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64                                      4/14 
  正在更新    : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64                                                5/14 
  正在更新    : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64                                 6/14 
  正在更新    : 7:lvm2-2.02.187-6.el7_9.5.x86_64                                                     7/14 
  清理        : 7:lvm2-2.02.171-8.el7.x86_64                                                         8/14 
  清理        : 7:lvm2-libs-2.02.171-8.el7.x86_64                                                    9/14 
  清理        : 7:device-mapper-event-1.02.140-8.el7.x86_64                                         10/14 
  清理        : 7:device-mapper-event-libs-1.02.140-8.el7.x86_64                                    11/14 
  清理        : 7:device-mapper-1.02.140-8.el7.x86_64                                               12/14 
  清理        : 7:device-mapper-libs-1.02.140-8.el7.x86_64                                          13/14 
  清理        : device-mapper-persistent-data-0.7.0-0.1.rc6.el7.x86_64                              14/14 
  验证中      : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64                                                1/14 
  验证中      : 7:device-mapper-1.02.170-6.el7_9.5.x86_64                                            2/14 
  验证中      : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64                                 3/14 
  验证中      : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64                                      4/14 
  验证中      : 7:lvm2-2.02.187-6.el7_9.5.x86_64                                                     5/14 
  验证中      : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64                                       6/14 
  验证中      : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64                                 7/14 
  验证中      : 7:device-mapper-event-libs-1.02.140-8.el7.x86_64                                     8/14 
  验证中      : 7:device-mapper-event-1.02.140-8.el7.x86_64                                          9/14 
  验证中      : 7:lvm2-libs-2.02.171-8.el7.x86_64                                                   10/14 
  验证中      : 7:device-mapper-1.02.140-8.el7.x86_64                                               11/14 
  验证中      : 7:device-mapper-libs-1.02.140-8.el7.x86_64                                          12/14 
  验证中      : 7:lvm2-2.02.171-8.el7.x86_64                                                        13/14 
  验证中      : device-mapper-persistent-data-0.7.0-0.1.rc6.el7.x86_64                              14/14 

更新完毕:
  device-mapper-persistent-data.x86_64 0:0.8.5-3.el7_9.2         lvm2.x86_64 7:2.02.187-6.el7_9.5        

作为依赖被升级:
  device-mapper.x86_64 7:1.02.170-6.el7_9.5              device-mapper-event.x86_64 7:1.02.170-6.el7_9.5  
  device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5   device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5   
  lvm2-libs.x86_64 7:2.02.187-6.el7_9.5                 

完毕!
[root@localhost ~]# yum-config-manager --add-repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
adding repo from: https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
grabbing file https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@localhost ~]# sed -i 's@download.docker.com@mirrors.tuna.tsinghua.edu.cn/docker-ce@g' /etc/yum.repos.d/docker-ce.repo
[root@localhost ~]# sed -i 's/$releasever/7/g' /etc/yum.repos.d/docker-ce.repo
[root@localhost ~]# sed -i 's/$basearch/x86_64/g' /etc/yum.repos.d/docker- ce.repo
sed:无法读取 /etc/yum.repos.d/docker-:没有那个文件或目录
sed:无法读取 ce.repo:没有那个文件或目录
[root@localhost ~]# yum makecache fast
已加载插件:fastestmirror, langpacks
base                                                                               | 3.6 kB  00:00:00     
docker-ce-stable                                                                   | 3.5 kB  00:00:00     
extras                                                                             | 2.9 kB  00:00:00     
updates                                                                            | 2.9 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
元数据缓存已建立
[root@localhost ~]# yum -y install docker-ce
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
软件包 3:docker-ce-20.10.17-3.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo--2022-08-16 21:14:02--  http://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 113.141.190.104, 113.141.190.105, 27.128.214.223, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|113.141.190.104|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”

100%[================================================================>] 2,523       --.-K/s 用时 0s      

2022-08-16 21:14:02 (719 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])

[root@localhost ~]# yum -y install docker-ce
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 3:docker-ce-20.10.17-3.el7.x86_64 已安装并且是最新版本
无须任何处理
    修改 docker-ce
[root@localhost ~]# sed -i 's@download.docker.com@mirrors.tuna.tsinghua.edu.cn/docker-ce@g' /etc/yum.repos.d/docker-ce.repo
    更新源
[root@localhost ~]# yum makecache 
    安装 docker-ce
yum -y install docker-ce
    启动 docker 服务进程
[root@localhost data]# systemctl daemon-reload
[root@localhost data]# systemctl start docker

    查看版本信息

[root@localhost ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:05:12 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true


2、下载并查看镜像


    下载nginx的镜像,alpine的镜像

[root@localhost ~]# docker  pull nginx:1.14-alpine
1.14-alpine: Pulling from library/nginx
bdf0201b3a05: Pull complete 
3d0a573c81ed: Pull complete 
8129faeb2eb6: Pull complete 
3dc99f571daf: Pull complete 
Digest: sha256:485b610fefec7ff6c463ced9623314a04ed67e3945b9c08d7e53a47f6d108dc7
Status: Downloaded newer image for nginx:1.14-alpine
docker.io/library/nginx:1.14-alpine

    httpd的镜像并且给httpd镜像重新打标签为test/httpd:v1 

[root@localhost ~]# docker  pull httpd
Using default tag: latest
latest: Pulling from library/httpd
1efc276f4ff9: Pull complete 
aed046121ed8: Pull complete 
4340e7be3d7f: Pull complete 
80e368ef21fc: Pull complete 
80cb79a80bbe: Pull complete 
Digest: sha256:343452ec820a5d59eb3ab9aaa6201d193f91c3354f8c4f29705796d9353d4cc6
Status: Downloaded newer image for httpd:latest
docker.io/library/httpd:latest
[root@localhost ~]# docker tag httpd test/httpd:v1
[root@localhost ~]# docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
213ec9aee27d: Pull complete 
Digest: sha256:bc41182d7ef5ffc53a40b044e725193bc10142a1243f395ee852a8d9730fc2ad
Status: Downloaded newer image for alpine:latest
docker.io/library/alpine:latest

    以上过程即为所求,欢迎同行朋友予以斧正!万分感谢!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

春光犹上人间

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值