Docker安装(RPM包方式)

2023-10-30

Docker安装(RPM包方式)

一、安装环境准备

1、操作系统要求

#1、查看内核版本
[root@nod var]# uname -r
3.10.0-957.el7.x86_64
#2、查看操作系统版本
[root@nod var]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

#3、关闭防火墙
[root@nod var]# systemctl stop firewalld
[root@nod var]# systemctl disable firewalld
[root@nod var]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
#4、关闭SElinux
[root@nod var]vim /etc/selinux/config
[root@nod var]# getenforce
Disabled
#5、查看iptables是否被启动
[root@nod selinux]# systemctl status iptables
#若没有安装进行iptables进行安装
[root@nod selinux]# yum -y install iptables-services
#启动iptables
[root@nod selinux]# systemctl start iptables
#设置为开机自启
[root@nod selinux]# sysatemctl enable iptables
#查看iptables的状态
[root@nod selinux]# systemctl status iptables
● iptables.service - IPv4 firewall with iptables
   Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)
   Active: active (exited) since Thu 2021-12-02 10:18:29 CST; 31s ago
 Main PID: 3796 (code=exited, status=0/SUCCESS)

Dec 02 10:18:29 nod systemd[1]: Starting IPv4 firewall with iptables...
Dec 02 10:18:29 nod iptables.init[3796]: iptables: Applying firewall rules: [  OK  ]
Dec 02 10:18:29 nod systemd[1]: Started IPv4 firewall with iptables.
#清空防火墙
[root@nod selinux]# iptables -F
#保存防火墙
[root@nod selinux]# service  iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
#查看防火墙状态
[root@nod selinux]# iptables -nL
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

#建议更新软件包
[root@nod selinux]# yum update
#重启并使用最新的内核启动
[root@nod selinux]# shutdown -h now
#升级之后的内核版本
[root@nod ~]# uname -r
3.10.0-1160.49.1.el7.x86_64

2、判断是否存在老版本Docker进行卸载

root@nod system]# yum remove docker \
>                   docker-client \
>                   docker-client-latest \
>                   docker-common \
>                   docker-latest \
>                   docker-latest-logrotate \
>                   docker-logrotate \
>                   docker-engine
Loaded plugins: fastestmirror, langpacks
No Match for argument: docker-client-latest
No Match for argument: docker-latest
No Match for argument: docker-latest-logrotate
No Match for argument: docker-logrotate
No Match for argument: docker-engine
Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 2:1.13.1-96.gitb2f74b2.el7.centos will be erased
---> Package docker-client.x86_64 2:1.13.1-96.gitb2f74b2.el7.centos will be erased
---> Package docker-common.x86_64 2:1.13.1-96.gitb2f74b2.el7.centos will be erased
--> Finished Dependency Resolution
base/7/x86_64                                                                                                              | 3.6 kB  00:00:00     
extras/7/x86_64                                                                                                            | 2.9 kB  00:00:00     
kubernetes/signature                                                                                                       |  844 B  00:00:00     
kubernetes/signature                                                                                                       | 1.4 kB  00:00:00 !!! 
mysql-connectors-community/x86_64                                                                                          | 2.6 kB  00:00:00     
mysql-tools-community/x86_64                                                                                               | 2.6 kB  00:00:00     
mysql57-community/x86_64                                                                                                   | 2.6 kB  00:00:00     
nginx/x86_64                                                                                                               | 2.9 kB  00:00:00     
updates/7/x86_64                                                                                                           | 2.9 kB  00:00:00     
updates/7/x86_64/primary_db                                                                                                |  13 MB  00:00:02     

Dependencies Resolved

==================================================================================================================================================
 Package                          Arch                      Version                                              Repository                  Size
==================================================================================================================================================
Removing:
 docker                           x86_64                    2:1.13.1-96.gitb2f74b2.el7.centos                    @extras                     65 M
 docker-client                    x86_64                    2:1.13.1-96.gitb2f74b2.el7.centos                    @extras                     13 M
 docker-common                    x86_64                    2:1.13.1-96.gitb2f74b2.el7.centos                    @extras                    4.4 k

Transaction Summary
==================================================================================================================================================
Remove  3 Packages

Installed size: 77 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 2:docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64                                                                                1/3 
warning: /etc/sysconfig/docker-storage saved as /etc/sysconfig/docker-storage.rpmsave
  Erasing    : 2:docker-client-1.13.1-96.gitb2f74b2.el7.centos.x86_64                                                                         2/3 
  Erasing    : 2:docker-common-1.13.1-96.gitb2f74b2.el7.centos.x86_64                                                                         3/3 
warning: /etc/sysconfig/docker saved as /etc/sysconfig/docker.rpmsave
  Verifying  : 2:docker-client-1.13.1-96.gitb2f74b2.el7.centos.x86_64                                                                         1/3 
  Verifying  : 2:docker-common-1.13.1-96.gitb2f74b2.el7.centos.x86_64                                                                         2/3 
  Verifying  : 2:docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64                                                                                3/3 

Removed:
  docker.x86_64 2:1.13.1-96.gitb2f74b2.el7.centos                         docker-client.x86_64 2:1.13.1-96.gitb2f74b2.el7.centos                 
  docker-common.x86_64 2:1.13.1-96.gitb2f74b2.el7.centos                 

Complete!

[root@nod var]# rm -rf /var/lib/docker/

3、安装Docker

3.1、下载Docker安装包
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
下载rpm包:
docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm 
docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm   
3.2、上传Docker安装包
#1、把docker安装包上传到/root/docker目录下
[root@nod ~]# mkdir docker
[root@nod ~]# cd docker/
[root@nod docker]# ll
total 19096
-rw-r--r-- 1 root root 19521288 Dec  2 18:55 docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
-rw-r--r-- 1 root root    29108 Dec  2 18:55 docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm

#2、到/root/docker目录下执行安装
[root@nod docker]# yum -y install *
#5、启动docker、设置开机自启
[root@nod docker]# systemctl start docker
[root@nod docker]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@nod docker]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-12-02 19:03:22 CST; 3min 31s ago
     Docs: https://docs.docker.com
 Main PID: 15149 (dockerd)
    Tasks: 16
   Memory: 18.6M
   CGroup: /system.slice/docker.service
           ├─15149 /usr/bin/dockerd
           └─15152 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/li...

Dec 02 19:03:21 nod dockerd[15149]: time="2021-12-02T19:03:21.669802339+08:00" level=info msg="libcontainerd: new containerd process, pid: 15152"
Dec 02 19:03:22 nod dockerd[15149]: time="2021-12-02T19:03:22.708279181+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Dec 02 19:03:22 nod dockerd[15149]: time="2021-12-02T19:03:22.708753767+08:00" level=info msg="Loading containers: start."
Dec 02 19:03:22 nod dockerd[15149]: time="2021-12-02T19:03:22.750365984+08:00" level=info msg="Firewalld running: false"
Dec 02 19:03:22 nod dockerd[15149]: time="2021-12-02T19:03:22.802537319+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0...IP address"
Dec 02 19:03:22 nod dockerd[15149]: time="2021-12-02T19:03:22.917607672+08:00" level=info msg="Loading containers: done."
Dec 02 19:03:22 nod dockerd[15149]: time="2021-12-02T19:03:22.924340194+08:00" level=info msg="Daemon has completed initialization"
Dec 02 19:03:22 nod dockerd[15149]: time="2021-12-02T19:03:22.924378985+08:00" level=info msg="Docker daemon" commit=3a232c8 graphdriver=overlay version=17.03.0-ce
Dec 02 19:03:22 nod dockerd[15149]: time="2021-12-02T19:03:22.937997324+08:00" level=info msg="API listen on /var/run/docker.sock"
Dec 02 19:03:22 nod systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
[root@nod docker]# docker version
Client:
 Version:      17.03.0-ce
 API version:  1.26
 Go version:   go1.7.5
 Git commit:   3a232c8
 Built:        Tue Feb 28 08:10:07 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.03.0-ce
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   3a232c8
 Built:        Tue Feb 28 08:10:07 2017
 OS/Arch:      linux/amd64
 Experimental: false
 [root@nod docker]# docker version
Client:
 Version:      17.03.0-ce
 API version:  1.26
 Go version:   go1.7.5
 Git commit:   3a232c8
 Built:        Tue Feb 28 08:10:07 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.03.0-ce
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   3a232c8
 Built:        Tue Feb 28 08:10:07 2017
 OS/Arch:      linux/amd64
 Experimental: false
 #运行hello的镜像
 [root@nod docker]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
Status: Downloaded newer image for hello-world:latest

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/
 
 

二进制包的安装方式(生产下不建议使用)参考:https://blog.csdn.net/ruth13156402807/article/details/116457261

官方文档:https://docs.docker.com/engine/install/binaries/

4、Docker卸载

#1、卸载依赖
yum remove docker-ce docker-ce-li containerd.io
#2、删除资源
rm -rf /var/lib/docker

5、Docker国内镜像

#1、创建或修改/etc/docker/daemon.json文件
[root@nod docker]# vim /etc/docker/daemon.json
{
        "registry-mirrors":["https://4jxxx3m1.mirror.aliyuncs.com"]
}

#2、加载资源,重启docker
[root@nod docker]# systemctl daemon-reload
[root@nod docker]# systemctl restart docker
#3、通过docker info查看当前镜像库
[root@nod ~]# docker info
Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 2
Server Version: 17.03.0-ce
Storage Driver: overlay
 Backing Filesystem: xfs
 Supports d_type: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 977c511eda0925a723debdc94d09459af49d082a
runc version: a01dafd48bc1c7cc12bdb01206f9fea7dd6feb70
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-1160.49.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 3.84 GiB
Name: nod
ID: C2ZM:GVN6:EQJQ:ZFKA:ORO4:5HOW:A25A:6TYF:4H3R:UFB6:NW7Z:UWZV
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Registry Mirrors:
 https://4xxxx3m1.mirror.aliyuncs.com
Live Restore Enabled: false
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Docker安装(RPM包方式) 的相关文章

随机推荐

  • 自动化测试相关

    bug的风险等级 建议 一般 严重 致命 bug的生命周期 新建 待修复 审核 关闭 注意 bug关闭后可能会再次打开 测试人员关闭一个bug后需要做回归测试 验证次bug是否会引入新的bug 如果没有 则代表该bug彻底关闭 软件测试的流
  • Basic Level 1003 我要通过! (20分)

    题目 答案正确 是自动判题系统给出的最令 人欢喜的回复 本题属于PAT的 答案正确 大派送 只要读入的字符 满足下列 条件 系统就输出 答案正确 否则输出 答案错误 得到 答案正确 的条件是 1 字符 中必须仅有P A T这三种字符 可以包
  • 【已解决】mysqld: File ‘.\杩滅▼浼氳瘖-鐥呯悊绉?slow.log‘ not found (Errcode: 2 - No such file or directory)

    卸载mysql 删除和mysql相关的文件 MySQL踩坑 含泪填完 MySQL踩坑 含泪填完 1 控制面板 删除之前安装失败的mysql对应的版本 2 删除C Program Files x86 MySQL下的文件夹 见下图 3 显示隐藏
  • 懒汉式之并发安全问题

    在高并发场景下的懒汉式创建对象 造成ID重复创建 代码见下图 并发场景下 iDCreator对象并未随类的创建而创建 而是在需要的时候进行创建 导致垃圾回收器可以对其进行回收 从而有可能同一时间戳 前后两次的对象不一致 造成出现两个不同的i
  • redis 主从配置参数详解

    转 https www cnblogs com chenmh p 5121849 html undefined 安装redis 下载redis wget http download redis io releases redis 3 0 7
  • 基于51单片机的温控风扇设计

    作者 何朋伟 19计科一班 宏定义 define uchar unsigned char define uint unsigned int 包含头文件 include
  • Java系统多个JSSE认证

    问题描述 由于项目需要 系统需要多个JSSE认证 登录使用SSL 邮件收取 解决办法 一 对于需要一次JSSE认证来说 可以通过 1 InstallCert工具来安装证书 Copyright 2006 Sun Microsystems In
  • 模型实战(10)之win10下tensorRT部署yolov5算法

    win10下tensorRT部署yolov5算法 针对yolov5的众多版本 目前有几种部署方法 1 tensorrtx 大神针对众多网络模型 包含yolov5众多版本 开源的一个转换工具 部署方式为 onnx gt wts gt engi
  • egret native使用自定义字体

    参考文章白鹭官方链接 除了文章提到的修改内容 还有文章没提到的一些内容如下 1 在egretProperties json文件中添加字库名称 2 添加字库资源 以上是android apk包内改变字体的方法 而移动端浏览器的设置方法则需要另
  • 关于layer.js中layer.confirm弹出框看不到或者不居中问题处理

    在jsp页面body 标签上加上style height 100 就可以解决
  • 在Android中实现Unity3D的背景是透明的 u3d显示在安卓的上一层

    在Unity中 可以通过设置Camera的背景 Camera下的Environment下的Background Type设置为Solid Color Background需要设置黑色透明度0 即ARGB为 0 0 0 0 透明度不为0则无法
  • 安卓应用开发入门:两个 Activity 之间的跳转

    关键知识 Intent Intent 意图 主要实现Activity之间的来回切换和数据传递 Intent是一种轻量级的消息传递机制 这种消息描述了应用中一次操作的动作 动作涉及数据 附加数据 Android系统根据此Intent的描述 负
  • 凭借这份面经,大专的我成功拿到腾讯Android岗offer

    一 简历 网上有很多对程序员简历的一些指导 这里就不重述 大家可以搜下网上其他大神的总结 结合自身情况修改下 我有几点建议 1 尽量不要花哨 程序员和设计师或者产品运营还不一样 我们的简历成功与否决定权还是在技术面试官那 而他们看重的是你的
  • centos6.8下l2tp客户端xl2tpd的安装配置

    环境 DigitalOcean centos6 8作为l2tp客户端 ros6 43 8作为l2tp服务端 1 安装xl2tp和ppp rpm ivh http mirrors yun idc com epel 6 x86 64 epel
  • 你能活过80岁么?9大因素决定人的寿命

    你能活过80岁么 9大因素决定人的寿命 最近 一项世界上历时最长 规模最大的老龄化研究显示 对中年男子而言 寿命能否达到80岁以上 取决于9项指标 即体重 血压 血糖 胆固醇 受教育程度 婚姻状况 是否酗酒 是否吸烟以及是否拥有好的握力 这
  • 测试音质好坏的软件,音响音质的好坏简单的两招测出

    原标题 音响音质的好坏简单的两招测出 怎样判断一个音响好坏 对于略懂略懂的你真的可以判断一个音响的好坏 当没有专业的测试工具也没有精确的仪器时候 应该怎样判断一个音响好坏 然后就买买买 低配置的测试 工具 一杯水 一首无损音质的歌曲 测试低
  • Android实现屏幕旋转方法

    本文实例总结了Android实现屏幕旋转方法 分享给大家供大家参考 具体如下 在介绍之前 我们需要先了解默认情况下android屏幕旋转的机制 默认情况下 当用户手机的重力感应器打开后 旋转屏幕方向 会导致当前activity发生onDes
  • 金融分析与风险管理——投资组合的有效前沿及资本市场线

    金融分析与风险管理 投资组合的有效前沿及资本市场线 1 投资组合的可行集 2 投资组合的有效前沿 3 资本市场线 1 投资组合的可行集 投资组合中的权重变量可以实现投资组合的预期收益率与收益波动率之间的映射关系 在投资组合的理论中 所有可能
  • Tomcat服务安全加固和优化

    转载来源 https help aliyun com knowledge detail 37421 html spm a2c4g 11186623 4 5 4ad6510eY2UhOS 介绍 tomcat服务默认启用了管理后台功能 使用该后
  • Docker安装(RPM包方式)

    Docker安装 RPM包方式 一 安装环境准备 1 操作系统要求 1 查看内核版本 root nod var uname r 3 10 0 957 el7 x86 64 2 查看操作系统版本 root nod var cat etc os