I tried mounting the /var/hyperledger/production folder to the host (I'm using Windows 7 and running Docker through Docker ToolBox) so that the enrollment certificates will be retained when my hyperledger peer docker container exits.
Here is the command I used:
docker run --name c_vp0 --rm -it -v /var/run/docker.sock:/var/run/docker.sock -v /c/Users/hyperledger/production:/var/hyperledger/production -e CORE_VM_ENDPOINT=unix:///var/run/docker.sock -e CORE_PEER_ID=vp0 -e CORE_PEER_ADDRESSAUTODETECT=true -e CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=noop -e CORE_LOGGING_LEVEL=ERROR -e CORE_SECURITY_ENABLED=true -e CORE_SECURITY_PRIVACY=true -e CORE_PEER_PKI_ECA_PADDR=172.17.0.50:7054 -e CORE_PEER_PKI_TCA_PADDR=172.17.0.50:7054 -e CORE_PEER_PKI_TLSCA_PADDR=172.17.0.50:7054 -e CORE_SECURITY_ENROLLID=test_vp0 -e CORE_SECURITY_ENROLLSECRET=MwYpmSRjupbT hyperledger/fabric-peer peer node start
However, I encounter the following error:
panic: Error opening DB: IO error: directory: Invalid argument
I modified the command "peer node start" to "/bin/bash" so that I can inspect the mounted directory. I noticed that the ownership/group of /var/hyperledger/production (and its subdirectories and files) is 1000:staff instead of root:root.
I'm not sure if this is causing the problem but I tried using the chown command to change the ownership/group to root:root but it does not work.
There seems to be incompatibilities between leveldb and the vboxfs used by VirtualBox (see example here). I'm not sure who is at fault, but search results show success when using leveldb on volumes mounted without vboxfs.
Upgrade from Docker Toolbox, which uses VirtualBox, to Docker for Windows, which used Window's built in Hyper-V virtualization.
If you can't run Docker for Windows (e.g. you will need to upgrade your Windows 7 to at least Windows 10, then attempt to mount
/var/hyperledger/production
to your host folder via some other method such as NFS.