I setup Hyperledger Fabric V0.6 with docker image. I wrote small chain code program and perform some operations. Data is getting stored and fetched on request from Hyperledger blockchain.
I restart my chaincode program and data still persist. Ofcouse this should be expected behaviour.
But when I stop my Hyperledger fabric with command docker-compose down and start it again with docker-compose start and then start my chaincode program, I found that the whole data which was written before restart is gone. I couldn't find any data in my blockchain.
How can I avoid this behaviour of Hyperledger? I am running it on single peer/node. With multiple peers, if one of the peer restarted, then data/transactions from other peers get copied on it. But consider a worst scenario when all peers down. Does that mean we loose all our data?
As per the official docs
docker-compose down stops and removes all containers listed in docker-compose file along with their volumes (unless specified as external, have a look into the documentation).
You may want to stop the containers with
docker-compose stop - this way after
docker-compose up their data will be preserved.
If data persistence is desired on the peer container or the CouchDB container, one option is to mount a directory in the docker-host into a relevant directory in the container. For example, you may add the following two lines in the peer container specification in the
For the CouchDB container, you may add the following two lines in the CouchDB container specification: