Linux下docker的安装


前言

      因为之前在自己的mac上直接使用HomeBrew的包管理安装的,使用brew install docker即可,这种方法简单,但最近想尝试在Linux下安装,费了一些时间,主要是启动docker时报异常 Failed to start docker.service: Unit not found.下面是自己安装的步骤。

     安装前准备:

  •      先查看linux内核信息及操作系统信息

  1.       linux版本及内核信息可用 uname -a ,从下图可知,内核为64位版本为3.10.0 

  2.       cat /proc/version //查看当前操作系统版本信息

  3.       cat /etc/redhat-release  //查看版本当前操作系统发行版信息

  4.      从图中可知linux内核为3.10.0 操作系统发行版本为Red Hat 7.2

  • 官网上写的从Read Hat 7开始才支持安装
    Docker is supported on Red Hat Enterprise Linux 7.
    Docker requires a 64-bit OS and version 3.10 or higher of the Linux kernel.

    官网地址https://docs.docker.com/install/linux/docker-ee/rhel/#prerequisites
    • 所以环境准备完全满足

     安装:

  •  下载安装libcgroup的rpm包(该软件包提供了一系列工具和库文件用于控制和管理控制组)
  1. 下载libcgroup的rpm包: wget ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6.5/x86_64/updates/fastbugs/libcgroup-0.40.rc1-6.el6_5.1.x86_64.rpm
  2. 安装libcgroup的rpm包: rpm -ivh libcgroup-0.40.rc1-6.el6_5.1.x86_64.rpm
  •  更新yum源(当前yum源里可能没有docker):    
  1. 先下载epel的rpm包:        wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
  2. 安装epel的rpm包:rpm -ivh epel-release-latest-6.noarch.rp
  • 安装docker: yum install docker-io

 

  •  安装完后启动docker的服务:service docker start 后报unit not found,如下图所示

 

  • 经过查询说是在目录/usr/lib/systemd/system下少一个docker.socket的文件,但是安装的docker是1.13.1的版本不需要此文件的; 
  • 无奈之下,之后重新安装,仍然使用yum install docker-io 命令;
  • 此时奇迹出现了,再次使用service docker start时,启动成功了;

 

 


     

     

 

posted @ 2018-07-12 00:41  纵码万水千山  阅读(9792)  评论(0编辑  收藏  举报