Running Grin Node and Wallet With Docker
Grin is an experimental and innovative cryptocurrency that recently (Jan 2019 was the go-live date) appeared on the stage. I believe it has all chances to become a solid supplement to Bitcoin with Bitcoin being a SoV and Grin used as a fiat replacement. In any case, this is only my opinion and the future will tell whether I was right or wrong.
Since it is a new, unstable, experimental thing it would be wise to either run it on dedicated hardware or inside a VM, to protect ourselves from being exploited via bugs in the node and/or wallet. The additional benefit of this approach is flexibility: even though Grin only supports OSX and Linux for the time being running it in a Docker container means we can run it on all platforms Docker supports.
I have created a lightweight Docker image using the latest binary build of Grin. So, let’s get the ball rolling.
Node initialization
First, create a volume to hold node and wallet data:
docker volume create grin-node-data
Pull the image:
docker pull akatasonov/grin-node:latest
Start the node. You can do this both in the interactive mode (-it) or not:
docker run -it --name grin-node -v grin-node-data:/data akatasonov/grin-node
Wallet initialization
- Start the wallet. We’re going to use the same image but override the entry point
- The wallet should be in the node network to talk to it
- Publish the wallet port to the host so we can send/receive grins to/from the outside
docker run -it --name grin-wallet -v grin-node-data:/data --network="container:grin-node" -p 3415 --entrypoint=/bin/sh akatasonov/grin-node
In the command line of the grin-wallet node:
cd /data
/grin/grin wallet init
At this point, the grin node should be up, running and syncing the blockchain. To check the wallet balance (in the interactive shell for the grin-wallet container):
cd /data
/grin/grin wallet info
To start the wallet in the listen mode (to receive a transaction for example):
cd /data
/grin/grin wallet -e listen
We should check what port on the host is the wallet’s port mapped to. The wallet port is 3415 but that port will be open inside the container but on the host, it is going to be different:
docker ps
The command above (should be run on the host) will output all running containers, including the grin-node and grin-wallet containers (assuming you didn’t exit them). Check the port mapping information for the grin-wallet container in the PORTS section. It shows the ports in the host -> container template.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fc7e477723b7 grin-node /bin/sh About a minute ago Up About a minute 0.0.0.0:32768->3415/tcp grin-wallet
In this case, our port is 32768. We can expose it (temporarily) to the outside world via a secure HTTPS tunnel using the free tool called ngrok:
ngrok http 32768
The tool will show you a random URL like https://23b34b23.ngrok.io
which you can then use to receive Grins via an HTTP/HTTPS transaction.
When the transaction is received you can exit/turn off docker containers for both grin-wallet and/or grin-node.
WARNING:
DO NOT DELETE THE grin-node-data
VOLUME. It has your wallet seed and data. It makes sense to copy it somewhere else just in case. You can do it easily with:
docker cp grin-node-data:/data /path/on/your/host/machine/to/copy/wallet/to
Happy Grinning! :)