从零构建Fabric开发运行环境手册(二):安装Docker及Docker-Compose

本文主要说明CentOS 7下的安装过程。

一、安装Docker

官网安装指南请参考这里。Ubuntu及其它操作系统的安装指南参考官网安装指南
fabric1.4要求docker版本不低于17.06.2-ce。

(1)准备工作

系统要求

Docker CE 支持 CentOS 7以后的版本:( 还好我们的操作系统满足了这个要求。超级账本全球技术委员会委员、超级账本(Hyperledger)大中华区技术工作组主席杨保华所著《Docker 入门与实践》详细分析到,其实就是要求内核版本不低于 3.10。
看看刚刚装好的2018年10月发布的CentOS 7.6,内核为3.10,刚刚满足条件。
在这里插入图片描述
再看看两年前发布的稳定版16.04的内核,4.4!不得不说CentOS内核更新太慢。
在这里插入图片描述

卸载旧版本

卸载旧版本是必要的准备工作。由于我这里是从零开始的,没有安装任何Docker,因此省略这一步骤。

#旧版本的 Docker 称为 docker 或者 docker-engine ,使用以下命令卸载旧版本:
  sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

(2) 安装

安装依赖包:

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

添加 yum软件源:

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

更新 yum 软件源缓存:

sudo yum makecache fast

安装 Docker CE:

sudo yum install docker-ce

(3) 启动Docker CE

sudo systemctl enable docker
sudo systemctl start docker

(4) 检查Docker是否正常安装

通过检查版本号来确认是否正常安装完成。

[root@localhost fabric]# docker  --version
Docker version 18.09.6, build 481bc77156

(5) 测试运行Docker项目Hello world

sudo docker run hello-world

下面是典型的运行输出。如果看到“Hello from Docker”,说明Docker安装一切顺利。

[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:6f744a2005b12a704d2608d8070a494ad1145636eeb74a570c56b94d94ccdbfc
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/

二、安装Docker-Compose

Compose 项目是 Docker 官方的开源项目,负责实现对 Docker 容器集群的快速编排。能够简化多个docker之间的协调工作。
fabric 1.4要求docker-compose的版本不低于1.14.我们这次来安装最新的版本。

(1) 确认最新的compose版本

从官方开源位置compose release page on GitHub上找到最新的稳定版的版本号。截止到本博文发文,最新的正式版本号是1.24.0. 注意,还有些RC版(Release Candidate,发布候选版,指最终版(RTM=Release To Manufacture)之前的最后一个版本),请根据自己的情况选择。
在这里插入图片描述

(2) 下载compose

注意根据上一步的调查结果更换为合适的版本号。目前最新版是1.24.0.
uname -s 可以取到操作系统名称“Linux”,uname -m可以取到cpu架构及位数。CentOS取出的是“x86_64”。
下面的下载命令意思就是下载适合于本操作系统的最新版本的docker-compose,并存储到/usr/local/bin下面。

sudo curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
(3) 设置执行权限
sudo chmod +x /usr/local/bin/docker-compose
(4) 检查安装是否正常完成
docker-compose --version

正常完成的情况下,会输出如下说明。(1.24.0版的情况)

docker-compose version 1.24.0, build 0aa59064
发布了73 篇原创文章 · 获赞 27 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/sitebus/article/details/90349856