kubernetes基础之安装docker-ce(超简单篇)

centos7.5上面安装docker-ce

目前大家用的最多的还是docker 的社区版本,这里简单的意思就是用yum进行安装部署,主要是前期的docker环境配置

  • 安装的主要步骤
  • 关闭selinux
  • 关闭防火墙
  • 配置阿里源和加速项
  • 安装docker
  • 启动docker
  • 验证是否成功

关闭selinux

[root@localhost ~]# vi /etc/selinux/config   #修改selinux配置文件,修改完这个配置文件后需要重启服务器生效的,但是如果说不想重启服务器的话,用下面的那个命令


# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

[root@localhost ~]# setenforce 0  #不重启服务器,临时关闭selinux



关闭防火墙


[root@localhost ~]# systemctl stop firewalld   #关闭防火墙

[root@localhost ~]# systemctl disable firewalld  #关闭防火墙开机自启
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

配置阿里源和加速项

[root@localhost ~]# yum -y install wget   #安装wget服务,下载repo文件,配置阿里yum源
已加载插件:fastestmirror
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                      | 3.6 kB  00:00:00     
extras                                                                                                                    | 2.9 kB  00:00:00     
updates                                                                                                                   | 2.9 kB  00:00:00     
(1/4): extras/7/x86_64/primary_db                                                                                         | 225 kB  00:00:00     
(2/4): base/7/x86_64/group_gz                                                                                             | 153 kB  00:00:00     
(3/4): updates/7/x86_64/primary_db                                                                                        | 5.6 MB  00:00:01     
(4/4): base/7/x86_64/primary_db                                                                                           | 6.1 MB  00:00:03     
正在解决依赖关系
--> 正在检查事务
---> 软件包 wget.x86_64.0.1.14-18.el7_6.1 将被 安装
--> 解决依赖关系完成

依赖关系解决

=================================================================================================================================================
 Package                        架构                             版本                                       源                              大小
=================================================================================================================================================
正在安装:
 wget                           x86_64                           1.14-18.el7_6.1                            base                           547 k

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

总下载量:547 k
安装大小:2.0 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/base/packages/wget-1.14-18.el7_6.1.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY0 B  --:--:-- ETA 
wget-1.14-18.el7_6.1.x86_64.rpm 的公钥尚未安装
wget-1.14-18.el7_6.1.x86_64.rpm                                                                                           | 547 kB  00:00:00     
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
 用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 软件包     : centos-release-7-5.1804.el7.centos.x86_64 (@anaconda)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : wget-1.14-18.el7_6.1.x86_64                                                                                                  1/1 
  验证中      : wget-1.14-18.el7_6.1.x86_64                                                                                                  1/1 

已安装:
  wget.x86_64 0:1.14-18.el7_6.1                                                                                                                  

完毕!


[root@localhost ~]# cd /etc/yum.repos.d/     #到yum的配置目录中来
[root@localhost yum.repos.d]# ls   #下面是没有阿里云的yum源的
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo
[root@localhost yum.repos.d]# 


[root@localhost yum.repos.d]# wget http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo  #下载阿里云的yum源
--2021-03-03 16:13:51--  http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 111.63.64.220, 111.63.179.219, 111.63.182.242, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|111.63.64.220|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1919 (1.9K) [application/octet-stream]
正在保存至: “docker-ce.repo”

100%[=======================================================================================================>] 1,919       --.-K/s 用时 0s      

2021-03-03 16:13:52 (246 MB/s) - 已保存 “docker-ce.repo” [1919/1919])

[root@localhost yum.repos.d]# ls   #下面出现了阿里的docker-ce源
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  docker-ce.repo
[root@localhost yum.repos.d]# 


[root@localhost yum.repos.d]# mkdir /etc/docker   #创建docker的加速目录
[root@localhost yum.repos.d]# vi /etc/docker/daemon.json   #创建并编辑docker的加速文件

{
"registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"]
}

安装docker

[root@localhost ~]# yum -y install docker-ce #安装docker,由于过程很长,没有粘贴

启动docket

[root@localhost ~]# systemctl start docker   #启动docker
[root@localhost ~]# systemctl enable docker  #添加到开机自启动里面
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.


验证下

[root@localhost ~]# docker info   #查看docker的相关信息
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.5
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc version: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-862.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 974.6MiB
 Name: localhost.localdomain
 ID: ZNHL:MBP3:4SQI:UEE4:B2VS:ED6P:6MFG:TQEQ:ZX5C:WSKP:NEQV:HTYO
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  https://b9pmyelo.mirror.aliyuncs.com/
 Live Restore Enabled: false

出现上面的相关信息,代表着我们的docker已经部署完了,是不是很简单哈


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

刘帅0952

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

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

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

打赏作者

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

抵扣说明:

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

余额充值