Docker-ce Centos8 笔记一:安装Docker-ce

Docker是一个建设企业及数据中心服务仓库的进程,通过裸金属机和虚拟机承载的MAC、windows和linux系统提供本地和远程软件服务,涉及应用软件镜像、系统镜像、虚拟化仓库(虚拟机)。它承载着灵活的、轻量级的、可移植的、松散耦合、可扩展的、安全的特性。

部署环境:
  系统:Centos8
    [root@localhost ~]# uname -r
      4.18.0-193.14.2.el8_2.x86_64
    [root@localhost ~]# cat /etc/redhat-release
      CentOS Linux release 8.2.2004 (Core)
  软件:Docker_CE latest
    [root@localhost ~]# docker -v
      Docker version 19.03.12, build 48a66213fe

卸载老docker版本(防止老版本docker的依赖包影响安装)
    [root@localhost ~]# yum remove docker \
       docker-client \
       docker-client-latest \
       docker-common \
       docker-latest \
       docker-latest-logrotate \
       docker-logrotate \
       docker-engine


i.通过国内mirrors获取docker-ce资源
  阿里云:https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  中国科技技术大学:https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
  Docker官方下载:https://download.docker.com/linux/centos/docker-ce.repo


ii.下载docker-ce的repo
  [root@localhost ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo


iii.更新yum缓存
  [root@localhost ~]# dnf makecache    //dnf 相对于yum来说是轻量级的,它们同为包管理器(安装、更新、删除),降低对内存的消耗;


iv.问题:解决containerd.io版本过低
  [root@localhost ~]# dnf install https://download.docker.com/linux/fedora/30/x86_64/stable/Packages/containerd.io-1.2.6-3.3.fc30.x86_64.rpm


v.安装docker-ce的依赖包
  [root@localhost ~]# dnf install -y yum-utils device-mapper-persistent-data lvm2


vi.安装docker-ce数据包
  [root@localhost ~]# dnf install -y docker-ce


vii.开启docker服务
  [root@localhost ~]# systemctl start docker


viii.docker服务加入开机启动
  [root@localhost ~]# systemctl enable docker
    Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.


ix.问题:docker服务无法启动
docker的/etc/docker/daemon.json文本内容,如下:      
    {
      "registry-mirrors": ["https://5***0wdp.mirror.aliyuncs.com"],       //远程镜像服务器地址
      "insecure-registries": ["192.168.1.102:4000"] },           //通过http协议访问仓库管理web
      "graph":"/data/docker"                       //自定义docker软件的安装目录
    }
  用逗号“,”分割,避免service无法启动;
一般情况,docker状态命令“systemctl status docker”log提示failed信息,由于目录/usr/lib/systemd/system/docker.service和/etc/docker/daemon.json 存在错误配置;


x.查看docker状态
  [root@localhost ~]# 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 Mon 2020-08-03 21:40:17 CST; 18s ago
    Docs: https://docs.docker.com
    Main PID: 35838 (dockerd)
    Tasks: 10
    Memory: 41.8M
    CGroup: /system.slice/docker.service
    └─35838 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
   Aug 03 21:40:16 localhost.localdomain dockerd[35838]: time="2020-08-03T21:40:16.780989114+08:00" level=i>
    Aug 03 21:40:16 localhost.localdomain dockerd[35838]: time="2020-08-03T21:40:16.801029788+08:00" level=w>
    Aug 03 21:40:16 localhost.localdomain dockerd[35838]: time="2020-08-03T21:40:16.801065229+08:00" level=w>
    Aug 03 21:40:16 localhost.localdomain dockerd[35838]: time="2020-08-03T21:40:16.801194904+08:00" level=i>
    Aug 03 21:40:17 localhost.localdomain dockerd[35838]: time="2020-08-03T21:40:17.301292877+08:00" level=i>
    Aug 03 21:40:17 localhost.localdomain dockerd[35838]: time="2020-08-03T21:40:17.666918985+08:00" level=i>
    Aug 03 21:40:17 localhost.localdomain dockerd[35838]: time="2020-08-03T21:40:17.697215147+08:00" level=i>
    Aug 03 21:40:17 localhost.localdomain dockerd[35838]: time="2020-08-03T21:40:17.697472227+08:00" level=i>
    Aug 03 21:40:17 localhost.localdomain dockerd[35838]: time="2020-08-03T21:40:17.717429365+08:00" level=i>
    Aug 03 21:40:17 localhost.localdomain systemd[1]: Started Docker Application Container Engine.


xi.检查docker版本
  [root@localhost ~]# docker -v
  Docker version 19.03.12, build 48a66213fe

 

参考Docker官方文档:https://docs.docker.com/engine/install/centos/

 

 

posted on 2020-08-11 16:34  gkhost  阅读(453)  评论(0编辑  收藏  举报

导航