A docker container to build a Zcash node from source and run it in a container.
1.6K
A docker container to build a ZCash node from source and run it in a container.
The "Zcash data" (i.e. blockchain data, wallet) are very large and not suitable for storing in the container’s writable layer. The Zcash data is large and to download/regenerate it each time you regenerate a container would be terrible. Also you may want to have multiple Zcash containers over time and you wouldn't want the local copy of the blockchain destroyed along with it. So the Zcash data is tored in Docker volumes. The Zcash blockchain data (i.e. the value for zcashd's -datadir arg) is stored in a Docker volume named zcash-datadir.
So if you kill the container and associated iamges and rebuild it, it will only pull and rebuild the source, it won't need to download and reindex the blockchain or zkSNARK parameters.
A couple key things to keep in mind with regards to security:
zcash-datadir volume above. So if you have any value stored in that wallet any other container that mounts it will have access to the wallet.zcash.conf file in the Dockerfile has other security elements in it that you need to be cautious about (e.g. rpcuser and rpcpassword).docker build -t zcash .
docker run --detach \
--name zc \
-P \
--mount source=zcash-datadir,target=/zcash-datadir \
zcash:latest
docker exec zc ./src/zcash-cli --datadir=/zcash-datadir stop
docker start zc
With the container running (in another tab if running interactively):
or for a streaming view of debug.log:
docker container exec zc tail -f /zcash-datadir/debug.log
to view the config:
docker container exec zc cat /zcash-datadir/zcash.conf
With the container running...
docdocker exec zc ./src/zcash-cli --datadir=/zcash-datadir help
docdocker exec zc ./src/zcash-cli --datadir=/zcash-datadir getinfo
docdocker exec zc ./src/zcash-cli --datadir=/zcash-datadir getnetworksolps
docdocker exec zc ./src/zcash-cli --datadir=/zcash-datadir getblockcount
ZHEAD=$(docker container exec --workdir /usr/src/zcash/zcash-src zc cat ./.git/FETCH_HEAD); docker container commit --message "zcash FETCH_HEAD $ZHEAD" zc zcash:container-backup
To run the saved image with mapping port 8000 on the host to port 8232 on the container (port 8232 is exposed in the Dockerfile, but this maps it to a specific host port):
docker run --detach --name zc --publish 8000:8232 zcash:latest
With the blockchain stored in the Docker Volume as described above you won't loose the blockchain when rebuilding the container. So to update to a new version in the source, just rebuild the image from the Dockerfile and update the ZCASH_TAG Docker ARG like. For example, to rebuild the container using the source tag v2.0.1-rc1, run the following:
docker build --build-arg ZCASH_TAG=v2.0.1-rc1 -t zcash:v2.0.1-rc1 .
docker container ls
Content type
Image
Digest
Size
3.1 GB
Last updated
about 8 years ago
docker pull activescott/zcash