澳门新浦京娱乐场网站-www.146.net-新浦京娱乐场官网
做最好的网站

澳门新浦京娱乐场网站:比特币测试网络

官网配置步骤:

安装Docker环境

什么是Docker?

Docker 属于 Linux 容器的一种封装,提供简单易用的容器使用接口。它是目前最流行的 Linux 容器解决方案。
Docker 将应用程序与该程序的依赖,打包在一个文件里面。运行这个文件,就会生成一个虚拟容器。程序在这个虚拟容器里运行,就好像在真实的物理机上运行一样。有了 Docker,就不用担心环境问题。

总体来说,Docker 的接口相当简单,用户可以方便地创建和使用容器,把自己的应用放入容器。容器还可以进行版本管理、复制、分享、修改,就像管理普通的代码一样。
Docker 的主要用途,目前有三大类。

(1)提供一次性的环境。比如,本地测试他人的软件、持续集成的时候提供单元测试和构建的环境。

(2)提供弹性的云服务。因为 Docker 容器可以随开随关,很适合动态扩容和缩容。

(3)组建微服务架构。通过多个容器,一台机器可以跑多个服务,因此在本机就可以模拟出微服务架构。

安装Docker
本文以ubuntu系统为例

centos7安装docker

澳门新浦京娱乐场网站:比特币测试网络。文章参考自:docker官方文档

ubuntu 安装docker-ce

安装Docker社区版仓库

  1. Update the apt package index:

    $ sudo apt-get update
    
  2. Install packages to allow apt to use a repository over HTTPS:

    $ sudo apt-get install 
        apt-transport-https 
        ca-certificates 
        curl 
        software-properties-common
    
  3. Add Docker’s official GPG key:

    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    
  4. Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well. To add the edge or test repository, add the word edge or test (or both) after the word stable in the commands below.

    $ sudo add-apt-repository 
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu 
       $(lsb_release -cs) 
       stable"
    

Install using the repository

Before you install Docker CE for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.

还可以参考菜鸟教程,中文,比较简单,菜鸟教程

- Install using the repository

  1. Update the apt package index:
$ sudo apt-get update
  1. Install packages to allow apt to use a repository over HTTPS:
$ sudo apt-get install 
    apt-transport-https 
    ca-certificates 
    curl 
    software-properties-common
  1. Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

$ sudo apt-key fingerprint 0EBFCD88
  1. Use the following command to set up the stable repository.
$ sudo add-apt-repository 
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu 
   $(lsb_release -cs) 
   stable"

安装Docker社区版

  1. Update the apt澳门新浦京娱乐场网站:比特币测试网络。 package index.

    $ sudo apt-get update
    
  2. Install the latest version of Docker CE, or go to the next step to install a specific version:

    $ sudo apt-get install docker-ce
    

   3.Verify that Docker CE is installed correctly by running the hello-world image.

    $ sudo docker run hello-world

Set up the repository

  1. Update the apt package index:

    $ sudo apt-get update
    
  2. Install packages to allow apt to use a repository over HTTPS:

    $ sudo apt-get install 
        apt-transport-https 
        ca-certificates 
        curl 
        software-properties-common
    
  3. Add Docker’s official GPG key:

    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    

    Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

    $ sudo apt-key fingerprint 0EBFCD88
    
    pub   4096R/0EBFCD88 2017-02-22
          Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
    uid                  Docker Release (CE deb) <docker@docker.com>
    sub   4096R/F273FCD8 2017-02-22
    
  4. Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well. To add the edge or test repository, add the word edge or test (or both) after the word stable in the commands below.

    Note: The lsb_release -cs sub-command below returns the name of your Ubuntu distribution, such as xenial. Sometimes, in a distribution like Linux Mint, you might need to change $(lsb_release -cs) to your parent Ubuntu distribution. For example, if you are using Linux Mint Rafaela, you could use trusty.

    • x86_64 / amd64
    • armhf
    • IBM Power (ppc64le)
    • IBM Z (s390x)
    $ sudo add-apt-repository 
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu 
       $(lsb_release -cs) 
       stable"
    

    Note: Starting with Docker 17.06, stable releases are also pushed to the edge and test repositories.

    Learn about stable and edge channels.

一、Install using the repository

由于我使用的是腾讯云centos服务器,参考菜鸟教程的安装过程中出现了could not resolve host mirrors.tencentyun.com no address associated with hostname trying other mirror错误,所以先解决掉此报错后就直接看官方文档了

- INSTALL DOCKER CE

  1. Update the apt package index.
$ sudo apt-get update
  1. Install the latest version of Docker CE, or go to the next step to install a specific version. Any existing installation of Docker is replaced.
$ sudo apt-get install docker-ce
  1. On production systems, you should install a specific version of Docker CE instead of always using the latest. This output is truncated. List the available versions.
$ apt-cache madison docker-ce
docker-ce | 17.12.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

The contents of the list depend upon which repositories are enabled. Choose a specific version to install. The second column is the version string. The third column is the repository name, which indicates which repository the package is from and by extension its stability level. To install a specific version, append the version string to the package name and separate them by an equals sign (=):

$ sudo apt-get install docker-ce=<VERSION>

The Docker daemon starts automatically.

  1. Verify that Docker CE is installed correctly by running the hello-world image.
$ sudo docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

截图如下

   澳门新浦京娱乐场网站 1

 

 

Install Docker CE

  1. Update the apt package index.

    $ sudo apt-get update
    
  2. Install the latest version of Docker CE, or go to the next step to install a specific version:

    $ sudo apt-get install docker-ce
    

    Got multiple Docker repositories?

    If you have multiple Docker repositories enabled, installing or updating without specifying a version in the apt-get install or apt-get update command always installs the highest possible version, which may not be appropriate for your stability needs.

  3. To install a specific version of Docker CE, list the available versions in the repo, then select and install:

    a. List the versions available in your repo:

    $ apt-cache madison docker-ce
    
    docker-ce | 18.03.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
    

    b. Install a specific version by its fully qualified package name, which is the package name (docker-ce) plus the version string (2nd column) up to the first hyphen, separated by a an equals sign (=), for example, docker-ce=18.03.0.ce.

    $ sudo apt-get install docker-ce=<VERSION>
    

    The Docker daemon starts automatically.

  4. Verify that Docker CE is installed correctly by running the hello-world image.

    $ sudo docker run hello-world
    

windows系统和Mac系统下载安装包点击安装就可以了。

  1. Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.

1. 如果之前有安装过docker但失败了,可以先remove之前版本:

Uninstall old versions:

$ sudo yum remove docker 
                  docker-common 
                  docker-selinux 
                  docker-engine

image文件

Docker 把应用程序及其依赖,打包在 image 文件里面。只有通过这个文件,才能生成 Docker 容器。image 文件可以看作是容器的模板。Docker 根据 image 文件生成容器的实例。同一个 image 文件,可以生成多个同时运行的容器实例。

image 是二进制文件。实际开发中,一个 image 文件往往通过继承另一个 image 文件,加上一些个性化设置而生成。举例来说,你可以在 Ubuntu 的 image 基础上,往里面加入 Apache 服务器,形成你的 image。

# 列出本机的所有 image 文件。
$ docker image ls

# 删除 image 文件
$ docker image rm [imageName]

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

2. Install Docker CE 安装docker:

  • Install using the repository
    Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
  • Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well.
$ sudo yum-config-manager 
    --add-repo 
    https://download.docker.com/linux/centos/docker-ce.repo
  • Optional: Enable the edge and test repositories. These repositories are included in the docker.repo file above but are disabled by default. You can enable them alongside the stable repository.
$ sudo yum-config-manager --enable docker-ce-edge
$ sudo yum-config-manager --enable docker-ce-test

获取iamge

docker image pull library/hello-world

查看本机的image

docker image ls

2.Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well.

3. INSTALL DOCKER CE

  • Update the yum package index
$ sudo yum makecache fast
  • Install the latest version of Docker CE, or go to the next step to install a specific version.
$ sudo yum install docker-ce
  • On production systems, you should install a specific version of Docker CE instead of always using the latest. List the available versions. This example uses the sort -r command to sort the results by version number, highest to lowest, and is truncated.
$ yum list docker-ce.x86_64  --showduplicates | sort -r

docker-ce.x86_64  17.06.0.el7                               docker-ce-stable  

运行image

docker container run hello-world

   yum-config-manager

4. Start Docker.

$ sudo systemctl start docker
  • Verify that docker is installed correctly by running the hello-world image.
$ sudo docker run hello-world

容器文件

image 文件生成的容器实例,本身也是一个文件,称为容器文件。

列出本机正在运行的容器

docker container ls

列出本机所有容器,包括终止运行的容器

docker container ls --all

移除容器

docker container rm [containerID]

--add-repo

安装比特币测试网络

 

下载比特币测试网络镜像

sudo docker pull freewill/bitcoin-testnet-box

运行Docker镜像

sudo docker run -it -p 19001:19001 -p 19011:19011 freewil/bitcoin-testnet-box

上述命令中的19001 和 19011是配置给两个节点提供RPC服务的端口。
-t:在新容器内指定一个伪终端或终端。

-i:允许你对容器内的标准输入 (STDIN) 进行交互。

启动比特币测试网络

make start

启动成功后,将在本地模拟运行两个比特币测试钱包节点,组成一个私有范围的比特币测试网络。

二、INSTALL DOCKER CE

查看节点信息

make getinfo

bitcoin-cli -datadir=1  getinfo
{
  "version": 130200,
  "protocolversion": 70015,
  "walletversion": 130000,
  "balance": 0.00000000,
  "blocks": 0,
  "timeoffset": 0,
  "connections": 1,
  "proxy": "",
  "difficulty": 4.656542373906925e-10,
  "testnet": false,
  "keypoololdest": 1523007398,
  "keypoolsize": 100,
  "paytxfee": 0.00000000,
  "relayfee": 0.00001000,
  "errors": ""
}
bitcoin-cli -datadir=2  getinfo
{
  "version": 130200,
  "protocolversion": 70015,
  "walletversion": 130000,
  "balance": 0.00000000,
  "blocks": 0,
  "timeoffset": 0,
  "connections": 1,
  "proxy": "",
  "difficulty": 4.656542373906925e-10,
  "testnet": false,
  "keypoololdest": 1523007399,
  "keypoolsize": 100,
  "paytxfee": 0.00000000,
  "relayfee": 0.00001000,
  "errors": ""
}

1.Update the yum package index.

产生一个区块

make generate

   $ sudo yum makecache fast

产生100个区块

make generate BLOCKS=100

2.Install the latest version of Docker CE, or go to the next step to install a specific version.

查看节点状态

bitcoin-cli -datadir=1  getinfo
{
  "version": 130200,
  "protocolversion": 70015,
  "walletversion": 130000,
  "balance": 5050.00000000,
  "blocks": 201,
  "timeoffset": 0,
  "connections": 1,
  "proxy": "",
  "difficulty": 4.656542373906925e-10,
  "testnet": false,
  "keypoololdest": 1523009413,
  "keypoolsize": 100,
  "paytxfee": 0.00000000,
  "relayfee": 0.00001000,
  "errors": ""
}

可以看到钱包节点中有5050个比特币

   $ sudo yum install docker-ce

查看钱包地址

比特币参考客户端维护了一个地址池,地址池的大小可以用 getinfo 命令keypoolsize 参数获取。这些地址是自动生成的,可以被用作公开接收地址或零钱地址。使用 getnewaddress 命令可以获得其中的一个地址:

bitcoin-cli -datadir=2 getnewaddress
mg1xSmdUdwGpwQTYaKLRnoG6pN1rCv6NhM

或者

make address2
bitcoin-cli -datadir=2  getnewaddress
mzHTLmnduaHZrTWpt2zJXrRSiqX1aoPqek

查看地址私钥

bitcoin-cli -datadir2  dumpprivkey 'mg1xSmdUdwGpwQTYaKLRnoG6pN1rCv6NhM'

给钱包2转账

make sendfrom1   ADDRESS=mg1xSmdUdwGpwQTYaKLRnoG6pN1rCv6NhM  AMOUNT=10

注意这里测试地址以m开头,和正式地址以1或3开头是有区别的。

确认交易

产生10个区块,让上面的交易得到足够的确认

make generate BLOCKS=10

然后查看节点二

bitcoin-cli -datadir=2 getinfo

可以看到 里面有10个比特币

tester@965cf497fb58:~/bitcoin-testnet-box$ bitcoin-cli -datadir=2 getinfo
{
  "version": 130200,
  "protocolversion": 70015,
  "walletversion": 130000,
  "balance": 10.00000000,
  "blocks": 210,
  "timeoffset": 0,
  "connections": 1,
  "proxy": "",
  "difficulty": 4.656542373906925e-10,
  "testnet": false,
  "keypoololdest": 1523019944,
  "keypoolsize": 100,
  "paytxfee": 0.00000000,
  "relayfee": 0.00001000,
  "errors": ""
}

查看第一个节点

tester@965cf497fb58:~/bitcoin-testnet-box$ bitcoin-cli -datadir=1 getinfo
{
  "version": 130200,
  "protocolversion": 70015,
  "walletversion": 130000,
  "balance": 5489.99996160,
  "blocks": 210,
  "timeoffset": 0,
  "connections": 1,
  "proxy": "",
  "difficulty": 4.656542373906925e-10,
  "testnet": false,
  "keypoololdest": 1523019944,
  "keypoolsize": 100,
  "paytxfee": 0.00000000,
  "relayfee": 0.00001000,
  "errors": ""
}
tester@965cf497fb58:~/bitcoin-testnet-box$

发现 balance 由 5500 变成了 5489.99996160,转账给节点2 10BTC,其余部分 0.0000384 就是支付给矿工记账的手续费。

三、INSTALL DOCKER CE

1.Update the yum package index.

   $ sudo yum makecache fast

2.Install the latest version of Docker CE, or go to the next step to install a specific version.

   $ sudo yum install docker-ce

  1. Start Docker.

   $ sudo systemctl start docker

4.Verify that docker is installed correctly by running the hello-world image.

   $ sudo docker run hello-world

本文由澳门新浦京娱乐场网站发布于澳门新浦京娱乐场网站,转载请注明出处:澳门新浦京娱乐场网站:比特币测试网络