From c0c83b8b49d281a6449e56dabf38096205108cdc Mon Sep 17 00:00:00 2001 From: Tobias Palmer Date: Fri, 11 May 2018 16:42:54 +0200 Subject: [PATCH] Docker node - Restart on crash - Wallet and account setup via CLI (because you need that anyway for the seed) - RPC sample - Updating - Bash alias via container name - Formatting --- Docker-node.md | 101 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 79 insertions(+), 22 deletions(-) diff --git a/Docker-node.md b/Docker-node.md index d6de62d..35c1f45 100644 --- a/Docker-node.md +++ b/Docker-node.md @@ -1,27 +1,32 @@ -The fastest way to set up a Nano node is via a docker container from DockerHub. You'll need a semi-recent version of docker, Client Version ~ 1.5.0. +[![Docker Pulls](https://img.shields.io/docker/pulls/nanocurrency/nano.svg)](https://hub.docker.com/r/nanocurrency/nano/) + +The fastest way to set up a Nano node is via a docker container from DockerHub. You'll need a semi-recent version of Docker, Client Version ~ 1.5.0. ### Installation instructions https://docs.docker.com/engine/installation -### Pulling docker image +### Pulling Docker image ```bash sudo docker pull nanocurrency/nano -``` +``` + ### Running ```bash -sudo docker run -d -p 7075:7075/udp -p 7075:7075 -p [::1]:7076:7076 -v ~:/root nanocurrency/nano +sudo docker run -d -p 7075:7075/udp -p 7075:7075 -p [::1]:7076:7076 -v ~:/root --restart=unless-stopped nanocurrency/nano ``` This command: -* Starts the docker container as a daemon "-d" -* Maps the network activity port "-p 7075:7075/udp" -* Maps the bootstrapping TCP port "-p 7075:7075" -* Maps the RPC control port to the local adapter only "-p [::1]:7076:7076" -* Maps the host's home directory to the guest /root directory "~:/root" -* Specifies the container to execute "nanocurrency/nano" + +* Starts the docker container as a daemon `-d` +* Maps the network activity port `-p 7075:7075/udp` +* Maps the bootstrapping TCP port `-p 7075:7075` +* Maps the RPC control port to the local adapter only `-p [::1]:7076:7076` +* Maps the host's home directory to the guest /root directory `~:/root` +* Restarts the container if it crashes `--restart=unless-stopped` +* Specifies the container to execute `nanocurrency/nano` This will put the data in a permanent location in your hosts's home directory, outside the docker container. @@ -33,27 +38,79 @@ If you get `create ~: volume name is too short, names should be at least two alp ### Setting up a wallet and adding accounts -`curl -d '{ "action" : "wallet_create" }' [::1]:7076` -The response will look like: -`{ "wallet" : "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F" }` -The number is the wallet ID that you can use to reference this wallet in other API commands. +You'll need the container ID for the following commands. You can get it with `sudo docker ps` e.g. `d9416b274092`. Replace `` with that ID. + +First create a new wallet: + +```bash +sudo docker exec /usr/bin/rai_node --wallet_create +``` + +You should get a wallet ID which you need in the next step. + +```bash +sudo docker exec /usr/bin/rai_node --account_create --wallet= +``` + +You get a new Nano address starting with xrb_1234… back. + +To get your seed execute: + +```bash +sudo docker exec /usr/bin/rai_node --wallet_decrypt_unsafe --wallet= +``` + +More information about the wallet backup is available here: [Wallet Backups](https://github.com/nanocurrency/raiblocks/wiki/Wallet-Backups) + +### RPC interface + +You can use the RPC interface on the local host via `curl`. -`curl -d '{ "action": "account_create", "wallet": "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F" }' [::1]:7076` -The response will look like: -`{ "account" : "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000" }` -This is the account number that was just created. +For example the version of the node: -Back up the wallet seed following the backup instructions https://github.com/nanocurrency/raiblocks/wiki/Wallet-Backups +```bash +curl -d '{ "action" : "version" }' [::1]:7076 +``` + +Or the blockcount: + +```bash +curl -d '{ "action" : "block_count" }' [::1]:7076 +``` + +All available RPC commands are listed here: [RPC protocol](https://github.com/nanocurrency/raiblocks/wiki/RPC-protocol) + +### Updating + +To update your container you need to rebuild it. + +**Make sure that you have your seed backup up!** + +First stop your old container: + +```bash +sudo docker stop +``` + +Then remove it: + +```bash +sudo docker rm +``` + +Then pull the new image and run the image just like you did at first start. ### Usability You can find reference material for using docker here: https://docs.docker.com/engine/reference/commandline/ +You can create a custom name for your container at the `docker run`command by adding e.g. `--name nanonode`. + Once set up, using bashrc to create an alias can save you time. -For example (when 97bf54657cdb is your docker container): +For example (when `nanonode` is the name your docker container): -`sudo docker exec 97bf54657cdb /usr/bin/rai_node --diagnostics` +`sudo docker exec nanonode /usr/bin/rai_node --diagnostics` Can be shortened to: @@ -61,4 +118,4 @@ Can be shortened to: By editing ~/.bashrc to add the alias: -`alias rai='sudo docker exec 97bf54657cdb /usr/bin/rai_node'` \ No newline at end of file +`alias rai='sudo docker exec nanonode /usr/bin/rai_node'` \ No newline at end of file