CentOS 7 安装配置Docker

CentOS 7 安装配置Docker

一、说明

Docker CE即社区免费版,Docker EE即企业版,强调安全,但需要付费使用。

旧版本的Docker被称为docker或docker-engine,如果已安装,请卸载它们。

二、环境配置

1. 将CentOS的源重新配置,先删除之前的源。

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# rm -rf *
[root@localhost yum.repos.d]# ls

2. 重新下载CentOS-Base.repo

登陆到阿里云官方镜像站,链接地址:https://developer.aliyun.com/mirror/,根据系统类别找到CentOS,下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/,命令如下:

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

或者

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

检查新的CentOS-Base.repo:

[root@localhost yum.repos.d]# cat CentOS-Base.repo 
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority

运行yum makecache生成缓存。

[root@localhost yum.repos.d]# yum makecache

3. 下载Epel镜像

EPEL (Extra Packages for Enterprise Linux), 是由 Fedora Special Interest Group 维护的 Enterprise Linux(RHEL、CentOS)中经常用到的包。

配置方法:

下载新repo到/etc/yum.repos.d/
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

4. 下载Docker CE镜像

简介

​ Docker CE 是免费的 Docker 产品的新名称,Docker CE 包含了完整的 Docker 平台,非常适合开发人员和运维团队构建容器 APP。

配置方法

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

5. Docker pull镜像加速

  1. 注册登陆DaoCloud账号,http://account.daocloud.io/signin:
image-20201102103538188
  1. 点击”项目“---点击红箭形状的加速图标:
image-20201102103720847
  1. 找到linux,执行如下代码并重启docker

    image-20201102103849207

    [root@web1 yum.repos.d]# curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
    docker version >= 1.12
    {"registry-mirrors": ["http://f1361db2.m.daocloud.io"]}
    Success.
    You need to restart docker to take effect: sudo systemctl restart docker 
    [root@web1 yum.repos.d]# cat /etc/docker/daemon.json 
    {"registry-mirrors": ["http://f1361db2.m.daocloud.io"]}
    [root@web1 yum.repos.d]# systemctl restart docker
    
  2. docker pull拉镜像

    [root@web1 yum.repos.d]# docker pull daocloud.io/centos:7
    7: Pulling from centos
    75f829a71a1c: Downloading [=====>                                             ]  8.936MB/75.86MB
    

你可能感兴趣的:(CentOS 7 安装配置Docker)