Closed Alihanoa closed 3 years ago
The problem lies in the fact, that the state is lost after the container are restarted, or after they are recreated? How to you handle persistence for the containers?
The most simple way is using bind mounts in docker-compose.
For both cases we don't know yet how to save the state, but the question was mainly related to the case when containers are restarted. I think your hint will help us for now. Thanks for your quick answer!
But my explanation is for the case of containers recreated. A container restart will keep its internal transient state. However, running docker-compose down
and docker-compose up
will destroy and re-create containers, in case you are using these commands.
Oh, okay, it looked like it would also fit to the case of a restart. Are these commands also executed internally when you click on the 'start' button in the upper right of the Docker desktop application (container view) or is it just a restart, which is performed?
I honestly don't know, I just use the command line to interact with docker. I would assume the button translates to docker start
command. Now, why would a restart of a container not persist the state? This is unexpected for me.
docker-compose down
doesn't remove volumes though. If you run docker-compose up
after down
, the diem testnet, it's accounts and transactions are still there. If you want a full blown reset you need to run docker-compose down -v
.
The delete button in docker for windows is just docker-compose down
and yes the play button seems to be docker start
(at least from my testing),
So the testnet is persistent, if restarting the validator-testnet (or even running docker-compose down and up).
I think i had a similar problem as yours and i also didn't find a way to save an "account" or "client", so thought of following solution:
With knowing that the testnet is persistent, you could just save every account address to a local text-file, and when you start running your code, you can just loop through the account addresses and get every account with client.getAccount(accountaddress)
.
That works, but leaves you without the privateKey of every account. So I also save the privateKeys seperatly because i'm just in a local testnet, but i don't know if this is the right way to do for you and your project. Saving privateKeys is a bit of a tricky topic i guess.
Thanks for your advices! With these hints we will check it and try again tomorrow at our next meeting. After this we will report back.
After doing all tutorials on the developers website of diem we aren't really enlighten on how to save created clients/minted coins etc. within the testnet. Currently we have the full-node and validator-testnet ready to use in docker as containers. Could you give us an advice or a source to look up on how we could deal with our problem?