github.com/pvitto98/fabric@v2.1.1+incompatible/images/peer/README.md (about)

     1  # Quick reference
     2  
     3  -	**Hyperledger Fabric project page**: https://www.hyperledger.org/projects/fabric
     4  
     5  -	**Where to get Docker help**:  
     6  	[the Docker Community Forums](https://forums.docker.com/),
     7  	[the Docker Community Slack](http://dockr.ly/slack),
     8  	or [Stack Overflow](https://stackoverflow.com/search?tab=newest&q=docker)
     9  
    10  -	**Where to get Hyperledger Fabric help**:  
    11  	[Fabric documentation](https://hyperledger-fabric.readthedocs.io/en/latest/),
    12  	[Stackoverflow](https://stackoverflow.com/questions/tagged/hyperledger-fabric),
    13  	or [Chat](https://chat.hyperledger.org/channel/fabric) ([Chat login help](https://wiki.hyperledger.org/display/CA/Logging+in+to+chat))
    14  
    15  -	**Where to get support**:
    16  	The Fabric images are provided for development and test purposes. Various vendors provide
    17  	supported offerings for production use.
    18  
    19  -	**Architectures available**:
    20  	amd64
    21  
    22  -	**Tags available**:
    23  	Architecture specific (e.g. `amd64-2.0.0`), release specific (e.g. `2.0.0`), and latest patch of minor release (e.g. `2.0`).
    24  
    25  -	**Image Dockerfile**:  
    26  	[Dockerfile location](https://github.com/hyperledger/fabric/blob/master/images/peer/Dockerfile)
    27  
    28  -	**Source of this description**:  
    29  	[Fabric github repository](https://github.com/hyperledger/fabric/blob/master/images/peer/README.md)
    30  
    31  # What is a Hyperledger Fabric peer?
    32  
    33  Hyperledger Fabric is an enterprise-grade permissioned distributed ledger framework for developing solutions and applications. Its modular and versatile design satisfies a broad range of industry use cases. It offers a unique approach to consensus that enables performance at scale while preserving privacy.
    34  
    35  The Fabric peer is the main runtime node that manages and provides access to the ledger.
    36  It receives blocks from an ordering service node and commits them to the ledger.
    37  
    38  # How to use this image
    39  
    40  ## Start a fabric peer
    41  
    42  You can run a Fabric peer container as follows:
    43  
    44  ```console
    45  $ docker run -d --publish 7051:7051 \
    46  -v /tmp/fabric/config/peer0.org1.example.com:/etc/hyperledger/fabric \
    47  -v /tmp/fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp \
    48  -v /tmp/fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls \
    49  -v /tmp/fabric/data/peer0.org1.example.com:/var/hyperledger/production \
    50  -v /var/run:/host/var/run \
    51  --name peer0.org1.example.com hyperledger/fabric-peer:2.0 peer node start
    52  ```
    53  
    54  In this example, a container will be started running the most recent 2.0.x patch for the
    55  Hyperledger Fabric peer, using name peer0.org1.example.com, and exposing the peer's 7051 port
    56  on the host as port 7051.
    57  
    58  Read on for a quick primer on the configuration and data volumes. For full details, see
    59  the [Hyperledger Fabric documentation](https://hyperledger-fabric.readthedocs.io/en/latest/).
    60  
    61  ## Configuring Fabric peer containers
    62  
    63  Three sets of configuration information need to be provided to a Fabric peer:
    64  
    65  - `core.yaml` configuration file
    66  - Membership service provider (MSP) directory for peer's membership credentials
    67  - tls directory for peer's tls credentials (if tls is configured)
    68  
    69  Let's look at each of these configuration inputs...
    70  
    71  ### core.yaml configuration file
    72  
    73  The peer image preconfigured environment variable `FABRIC_CFG_PATH` is used by the peer process to locate
    74  the `core.yaml` configuration file at runtime. `FABRIC_CFG_PATH` is preset to the image directory `/etc/hyperledger/fabric`.
    75  Inside this directory you'll find a default core.yaml configuration file with a SampleOrg organization (aka mspid) configured.
    76  
    77  You can provide your own `core.yaml` configuration file on your host, and then mount this directory inside your peer container at `/etc/hyperledger/fabric`, thereby overriding the default peer configuration. For example, your core.yaml may
    78  set `peer.localMspId` to your own organization's mspid.
    79  
    80  The `docker run` command above demonstrates how to mount such a configuration directory from your host to the
    81  peer container's `/etc/hyperledger/fabric` directory.
    82  
    83  Alternatively, you can override individual `core.yaml` configuration properties by passing
    84  environment variables to the peer container, for example `CORE_PEER_LOCALMSPID`.
    85  
    86  ### Membership service provider (MSP) directory for peer's membership credentials
    87  
    88  Because Hyperledger Fabric is a permissioned blockchain, the peer needs credentials to join a channel
    89  on a Fabric network. The credentials are a set of certificates and private keys that are issued
    90  by a certificate authority that has permissions for a certain organization on a Fabric network.
    91  These credentials can be generated by Fabric CA or the cryptogen utility (or by any CA for that matter),
    92  and then provided to a peer in a msp configuration directory. The peer image comes with a set of SampleOrg
    93  credentials in the msp directory. The msp directory location is set by `core.yaml` `peer.mspConfigPath`
    94  property, and by default it points to the `msp` directory within the `FABRIC_CFG_PATH` directory, (`/etc/hyperledger/fabric/msp`).
    95  
    96  As with the core.yaml directory, you can provide your own credentials msp directory on your host,
    97  and then mount this directory inside your peer container at `/etc/hyperledger/fabric/msp`, thereby
    98  overriding the default msp credentials.
    99  
   100  The `docker run` command above demonstrates how to mount such a msp directory from your host.
   101  
   102  ### tls directory for peer's tls credentials
   103  
   104  If your network components are configured for server-side tls, or mutual tls (server and client auth),
   105  you will also need to provide the peer with tls credentials. The default core.yaml sets
   106  `peer.tls.enabled` and `peer.tls.clientAuthRequired` to false. If setting to true, then you
   107  will need to provide tls credentials in a `tls` directory.
   108  
   109  As with the msp directory, you can provide your own credentials tls directory on your host,
   110  and then mount this directory inside your peer container at `/etc/hyperledger/fabric/tls`, to
   111  provide the peer with its tls credentials.
   112  
   113  The `docker run` command above demonstrates how to mount such a tls directory from your host.
   114  
   115  ## Where to Store Data
   116  
   117  There are several ways to store data used by applications that run in Docker containers.
   118  We encourage users of the Fabric images to familiarize themselves with the available options,
   119  especially the use of [volumes](https://docs.docker.com/storage/volumes/).
   120  
   121  The peer container by default writes data, including the blockchain ledger, to its
   122  `/var/hyperledger/production` directory, as configured by the `core.yaml` `peer.fileSystemPath` property.
   123  
   124  The `docker run` command above demonstrates how to use a data directory on the host system and then
   125  mount this to a directory visible from inside the container. This places the peer
   126  data files in a known location on the host system. The user needs to make sure that the host
   127  directory exists, and that the container has permissions to write to this directory.
   128  
   129  ## Docker daemon
   130  
   131  Finally, the `docker run` command above mounts the host's `/var/run` directory, so that the container
   132  can communicate with the Docker daemon via the socket defined in `/var/run/docker.sock`.
   133  
   134  ## Logging
   135  
   136  The peer log is available through Docker's container logging, for example to view the log
   137  for the peer container named peer0.org1.example.com:
   138  
   139  ```console
   140  $ docker logs peer0.org1.example.com
   141  ```
   142  Log levels are not configured in `core.yaml`. Instead, you can override the default INFO logging
   143  by setting environment variable FABRIC_LOGGING_SPEC when starting the container. For example,
   144  pass the FABRIC_LOGGING_SPEC environment variable within the `docker run` command as follows:
   145  
   146  `-e FABRIC_LOGGING_SPEC='info:kvledger,chaincode.platform=debug'`
   147  
   148  This would add ledger and chaincode build debug information to the peer log, which could be used
   149  to troubleshoot ledger or chaincode build issues.
   150  
   151  Alternatively, use the peer operations service to update the log level of a running peer. See the
   152  [Log Level Management documentation](https://hyperledger-fabric.readthedocs.io/en/latest/operations_service.html#log-level-management)
   153  for additional information.
   154  
   155  # Creating your own Fabric image
   156  
   157  You can use the Fabric Dockerfiles as an example of how to create your own Fabric images.
   158  Alternatively, you could use the Fabric images as the basis for your own images, for example to provide
   159  to your own `core.yaml` file within the image.
   160  
   161  # License
   162  
   163  Hyperledger Fabric is licensed under the [Apache License](https://github.com/hyperledger/fabric/blob/master/LICENSE).