简体   繁体   中英

Hyperledger Fabric BYFN - Unable to find directory listed in docker-compose-base.yaml

I am looking at docker-compose-base.yaml line 27:

volumes:
    - ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
    - ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
    - ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
    - orderer.example.com:/var/hyperledger/production/orderer

I can find below 3 directories on my filesystem

../channel-artifacts/genesis.block  
../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp  
../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/  

but I cannot find a directory named orderer.example.com . I think this is not meant to be a directory but related to the

container_name: orderer.example.com

in some way. Could anyone explain the meaning of the last mapping:

- orderer.example.com:/var/hyperledger/production/orderer

it does not look like a local <-> docker directory mapping. Then what is it?

Before starting the container it's normal that the orderer.example.com folder is not create, since it will be created when the container starts. Mount the directory /var/hyperledger/production/orderer between the host and the container can be useful if you orderer is run is solo mode.

Indeed, if your container crash (for example your server restart) you can keep track of the blocks that the orderer has build. It's can be used for restart the blockchain network easier (or move the orderer in other server) .

TL;DR: The first three

- ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
    - ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
    - ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls

are examples of bind mounts . The last one

- orderer.example.com:/var/hyperledger/production/orderer

is a volume . Its confusing because bind mounts can be created using the volume syntax and hence also get referred to as volumes in documentation.


This is not related to

container_name: orderer.example.com

docker-compose-base.yaml is a base file that is used eg, by docker-compose-e2e-template.yaml . In that file one can see volumes being defined:

volumes:
  orderer.example.com:
  peer0.org1.example.com:
  peer1.org1.example.com:
  peer0.org2.example.com:
  peer1.org2.example.com:

these volumes behave the same way as if one had created them using the docker volume create command. see https://docs.docker.com/engine/reference/commandline/volume_create/ to understand what that command does. It is a way to create persistent storage that 1. does not get deleted when the docker containers stop and exit and, 2. that can be used to share data amongst containers.

To see list of all volumes created by docker on the machine, run:

docker volume ls

To inspect a volume, run (to give an example):

$ docker volume inspect net_orderer.example.com
[
    {
        "CreatedAt": "2018-11-06T22:10:42Z",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/net_orderer.example.com/_data",
        "Name": "net_orderer.example.com",
        "Options": null,
        "Scope": "local"
    }
]

re: the original question:

Unable to find directory listed in docker-compose-base.yaml

You will not be able to find this directory. Eg, if you try listing the mountpoint above:

$ ls /var/lib/docker/volumes/net_orderer.example.com/_data
ls: /var/lib/docker/volumes/net_orderer.example.com/_data: No such file or directory

docker volumes are not created as regular directories on the host. The steps to "get" to a volume are quite complex in fact. see https://forums.docker.com/t/host-path-of-volume/12277/9 for details.


The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM