Running Node v0.6 in Docker

This document shows users how they can setup a simple 2 node network (can be scaled larger) and walks thorough the steps of getting them peer'd. This doc assumes you have the proper network configuration setup with your router, have generated your validator/account keys, and have contracts built locally.

For help with keys and contracts please see our documentation directory in Github. For opening ports on your router, if needed, please refer to your manufacturers documentation.


If you wish to get started quickly with running a network locally, please see hack/docker/README.md

If you wish to join an existing network, skip down to the Joining Existing Network Section.

Pulling the Latest Docker Images:

Bootstrap Setup
docker pull casperlabs/node:latest
docker pull casperlabs/client:latest
docker pull casperlabs/execution-engine:latest

Setup Bootstrap for New Network:

In my example I have my keys stored in my data directory. If you wish to store your keys elsewhere you will need to also mount that directory to the container. See docker's docs for examples.


Bootstrap Setup
# Docker only: If you are using docker to setup your nodes you must make sure the EE and Node containers are on the same network.
# For this demo, I created a network called "casperlabs"
bootstrap:~$ docker network create casperlabs

# Create the .casperlabs directory you plan to use for your node. Here I created it in my home directory.
bootstrap:~$ mkdir -p ~/.casperlabs

# Create the genesis directory
bootstrap:~$ mkdir -p ~/.casperlabs/genesis

# Create the bonds.txt file to be used by your network. This file should contain the Base64 validator-id of your nodes.
bootstrap:~$ vi ~/.casperlabs/genesis/bonds.txt

# Input the keys for each of your validators, in my case this will be 1 of them, and give them a weight on the network.
1KzamFTtaBw9Or1VypuruBvjeLIy3oBSSfw75Sj3ZVw= 10

# save and close your file

# Download the system contracts and untar them
curl -o ~/.casperlabs/genesis/system-contracts.tar.gz http://repo.casperlabs.io/casperlabs/repo/master/system-contracts.tar.gz
tar -xzvf ~/.casperlabs/genesis/system-contracts.tar.gz --directory ~/.casperlabs/genesis/

# We must start the execution-engine container before we start the node container.
# Note: You can name the container anything you wish, here I refer to it as cl-engine.
bootstrap:~$ docker run --rm --name cl-engine -dit -v ~/.casperlabs/:/root/.casperlabs/ --network casperlabs casperlabs/execution-engine:latest /root/.casperlabs/.caspernode.sock

# Next we can start the bootstrap node.
# Note: You can name the container anything you wish, here I refer to it as cl-boot.
# Note: This Bootstrap is started in readonly mode and is not a validator here. You can make it a validator by adding in additional flags. See the nodes help file for more details.

bootstrap:~$ docker run --rm --name cl-boot -dit --network casperlabs -p 40400-40405:40400-40405 -v ~/.casperlabs/:/root/.casperlabs/ casperlabs/node:latest run --server-data-dir=/root/.casperlabs --grpc-socket /root/.casperlabs/.caspernode.sock -s --casper-genesis-account-public-key-path /root/.casperlabs/genesis/validator-public.pem --casper-mint-code-path /root/.casperlabs/genesis/mint_token.wasm --casper-pos-code-path /root/.casperlabs/genesis/pos.wasm

# You can view the logs for the bootstrap while it is starting up. It's important to capture the address for your bootstrap (Listening for traffic on casperlabs://<address>),  which we will use later to start our other node.
# Once you see "Making the transition to block processing." the bootstrap is up and running.

bootstrap:~$ docker logs -f cl-boot
19:24:27.291 [main] INFO  io.casperlabs.node.Main$ - CasperLabs node 0.6.0 (260e9c292a40c90ceb94609b5b12cff2f5d69777)
19:24:27.305 [main] INFO  io.casperlabs.node.NodeEnvironment$ - Using data dir: /root/.casperlabs
19:24:27.749 [main] INFO  io.casperlabs.comm.UPnP$ - trying to open ports using UPnP....
19:24:36.823 [main] INFO  io.casperlabs.comm.UPnP$ - INFO - No gateway devices found
19:24:36.824 [main] INFO  io.casperlabs.comm.UPnP$ - No need to open any port
19:24:36.827 [main] INFO  io.casperlabs.comm.WhoAmI$ - flag --host was not provided, guessing your external IP address
19:24:36.951 [main] INFO  io.casperlabs.comm.WhoAmI$ - guessed 76.180.99.40 from source: AmazonAWS service
19:24:40.005 [main] INFO  o.f.c.i.license.VersionPrinter - Flyway Community Edition 5.2.4 by Boxfuse
19:24:40.181 [main] INFO  o.f.c.i.database.DatabaseFactory - Database: jdbc:sqlite:/root/.casperlabs/sqlite.db (SQLite 3.28)
19:24:40.243 [main] INFO  o.f.core.internal.command.DbValidate - Successfully validated 1 migration (execution time 00:00.034s)
19:24:40.253 [main] INFO  o.f.core.internal.command.DbMigrate - Current version of schema "main": 20190731.665
19:24:40.255 [main] INFO  o.f.core.internal.command.DbMigrate - Schema "main" is up to date. No migration necessary.
19:24:40.888 [main] WARN  i.c.blockstorage.FileDagStorage$ - CRC file /root/.casperlabs/dagstorage/latest-messages-crc did not contain a valid CRC value
19:24:40.922 [main] WARN  i.c.blockstorage.FileDagStorage$ - CRC file /root/.casperlabs/dagstorage/block-metadata-crc did not contain a valid CRC value
19:24:41.383 [main] INFO  io.casperlabs.node.api.Servers$ - Internal gRPC services started on port 40402.
19:24:41.437 [main] INFO  io.casperlabs.node.api.Servers$ - External gRPC services started on port 40401.
19:24:41.533 [main] INFO  io.casperlabs.node.MetricsRuntime - No Influx configuration found
19:24:41.556 [main] INFO  io.casperlabs.node.MetricsRuntime - Reporting metrics to InfluxDB disabled.
19:24:41.563 [main] INFO  io.casperlabs.node.MetricsRuntime - Reporting metrics to Prometheus disabled.
19:24:41.567 [main] INFO  io.casperlabs.node.MetricsRuntime - Reporting metrics to Zipkin disabled.
19:24:41.571 [main] INFO  io.casperlabs.node.MetricsRuntime - Reporting metrics to JMX.
19:24:41.608 [main] INFO  kamon.metrics.SystemMetrics - Starting the Kamon(SystemMetrics) module
19:24:42.313 [main] INFO  io.casperlabs.node.api.Servers$ - HTTP server started on port 40403.
19:24:43.341 [main] WARN  i.c.casper.ValidatorIdentity$ - No private key detected, cannot create validator identification.
19:24:43.391 [main] WARN  i.c.casper.ValidatorIdentity$ - No private key detected, cannot create validator identification.
19:24:43.395 [main] INFO  i.c.node.casper.gossiping.package$ - Starting without a validator identity.
19:24:43.403 [main] INFO  i.c.node.casper.gossiping.package$ - Starting in create genesis mode
19:24:43.408 [main] INFO  i.c.node.casper.gossiping.package$ - Constructing Genesis candidate...
19:24:43.421 [main] WARN  i.casperlabs.casper.genesis.Genesis$ - Specified wallets file /root/.casperlabs/genesis/wallets.txt does not exist. No wallets will exist at genesis.
19:24:43.544 [main] INFO  i.casperlabs.casper.genesis.Genesis$ - Reading Wasm code from /root/.casperlabs/genesis/mint_token.wasm
19:24:43.549 [main] INFO  i.casperlabs.casper.genesis.Genesis$ - Reading Wasm code from /root/.casperlabs/genesis/pos.wasm
19:24:44.200 [grpc-default-executor-0] INFO  i.c.node.casper.gossiping.package$ - Trying to store generated Genesis candidate 6c9c87c77d...
19:24:44.206 [grpc-default-executor-0] INFO  i.c.node.casper.gossiping.package$ - Validating genesis-like block 6c9c87c77d......
19:24:44.296 [grpc-default-executor-0] INFO  i.c.c.MultiParentCasperImpl$StatelessExecutor - Attempting to add Block with missing elements (6c9c87c77d...) to the DAG.
19:24:44.810 [grpc-default-executor-1] WARN  i.c.blockstorage.FileDagStorage$ - Block 6c9c87c77d6249acc79e5a495b8a55b1f150944b2b92baa2dd594e7a494fb9aa validator is empty
19:24:44.894 [grpc-default-executor-1] INFO  i.c.c.MultiParentCasperImpl$StatelessExecutor - Added 6c9c87c77d...
19:24:44.931 [grpc-default-executor-1] INFO  i.c.c.gossiping.GenesisApproverImpl - Transitioned to approved genesis state.
19:24:44.949 [node-runner-16] WARN  i.c.casper.ValidatorIdentity$ - No private key detected, cannot create validator identification.
19:24:45.077 [node-runner-16] INFO  i.c.node.casper.gossiping.package$ - Making the transition to block processing.
19:24:45.123 [grpc-default-executor-1] INFO  io.casperlabs.node.NodeRuntime - Starting stand-alone node.
19:24:45.135 [grpc-default-executor-1] INFO  io.casperlabs.node.NodeRuntime - Listening for traffic on casperlabs://2f1bf6ac0f99e90c0509c9e5aa1506969f0fd128@<ip>?protocol=40400&discovery=40404.
19:24:45.197 [blocking-io-40] INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
19:24:45.231 [blocking-io-40] INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.

# Note: -f flag will follow the log.  CTRL+C will exit or we can open a new terminal an continue to monitor the log.


Joining Existing Network:

In this example, I was joining the network above that existed on a different machine. The same method applies for networks local to your network but you may need to adjust the ports. See docker's doc on networking for details.

Node Setup
# Docker only: If you are using docker to setup your nodes you must make sure the EE and Node containers are on the same network.
# For this demo, I created a network called "casperlabs"
node:~$ docker network create casperlabs

# Create the .casperlabs directory you plan to use for your node. Here I created it in my home directory.
node:~$ mkdir -p ~/node2/.casperlabs

# We must start the execution-engine container before we start the node container.
# Note: You can name the container anything you wish, here I refer to it as cl-engine2.
node:~$ docker run --rm --name cl-engine2 -dit -v ~/node2/.casperlabs/:/root/.casperlabs/ --network casperlabs casperlabs/execution-engine:latest /root/.casperlabs/.caspernode.sock

# Next we can start our node. Here we will need the bootstrap address and the key pair we used in the bonds.txt file.
node:~$ docker run --rm --name cl-node -dit --network casperlabs -p 40400-40405:40400-40405 -v ~/node2/.casperlabs/:/root/.casperlabs/ casperlabs/node:latest run --server-data-dir /root/.casperlabs --grpc-socket /root/.casperlabs/.caspernode.sock --casper-validator-private-key-path /root/.casperlabs/validator-private.pem --casper-validator-public-key-path /root/.casperlabs/validator-public.pem --casper-auto-propose-enabled -b "casperlabs://<ADDRESS HERE>"

# You can view the logs for the node while it is starting up. Once fully started we should see it transition states and peer up to our bootstrap.
node:~$ docker logs -f cl-node
19:45:42.165 [main] INFO  io.casperlabs.node.Main$ - CasperLabs node 0.6.0 (260e9c292a40c90ceb94609b5b12cff2f5d69777)
19:45:42.183 [main] INFO  io.casperlabs.node.NodeEnvironment$ - Using data dir: /root/.casperlabs
19:45:42.534 [main] INFO  io.casperlabs.comm.UPnP$ - trying to open ports using UPnP....
19:45:51.609 [main] INFO  io.casperlabs.comm.UPnP$ - INFO - No gateway devices found
19:45:51.610 [main] INFO  io.casperlabs.comm.UPnP$ - No need to open any port
19:45:51.614 [main] INFO  io.casperlabs.comm.WhoAmI$ - flag --host was not provided, guessing your external IP address
19:45:51.732 [main] INFO  io.casperlabs.comm.WhoAmI$ - guessed <ip> from source: AmazonAWS service
19:45:55.050 [main] INFO  o.f.c.i.license.VersionPrinter - Flyway Community Edition 5.2.4 by Boxfuse
19:45:55.316 [main] INFO  o.f.c.i.database.DatabaseFactory - Database: jdbc:sqlite:/root/.casperlabs/sqlite.db (SQLite 3.28)
19:45:55.453 [main] INFO  o.f.core.internal.command.DbValidate - Successfully validated 1 migration (execution time 00:00.046s)
19:45:55.462 [main] INFO  o.f.c.i.s.JdbcTableSchemaHistory - Creating Schema History table: "main"."flyway_schema_history"
19:45:55.507 [main] INFO  o.f.core.internal.command.DbMigrate - Current version of schema "main": << Empty Schema >>
19:45:55.512 [main] INFO  o.f.core.internal.command.DbMigrate - Migrating schema "main" to version 20190731.665 - Create deploy tables
19:45:55.537 [main] INFO  o.f.core.internal.command.DbMigrate - Successfully applied 1 migration to schema "main" (execution time 00:00.068s)
19:45:56.423 [main] WARN  i.c.blockstorage.FileDagStorage$ - CRC file /root/.casperlabs/dagstorage/latest-messages-crc did not contain a valid CRC value
19:45:56.464 [main] WARN  i.c.blockstorage.FileDagStorage$ - CRC file /root/.casperlabs/dagstorage/block-metadata-crc did not contain a valid CRC value
19:45:56.688 [blocking-io-26] INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
19:45:56.764 [blocking-io-26] INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
19:45:56.975 [main] INFO  io.casperlabs.node.api.Servers$ - Internal gRPC services started on port 40402.
19:45:57.051 [main] INFO  io.casperlabs.node.api.Servers$ - External gRPC services started on port 40401.
19:45:57.163 [main] INFO  io.casperlabs.node.MetricsRuntime - No Influx configuration found
19:45:57.190 [main] INFO  io.casperlabs.node.MetricsRuntime - Reporting metrics to InfluxDB disabled.
19:45:57.197 [main] INFO  io.casperlabs.node.MetricsRuntime - Reporting metrics to Prometheus disabled.
19:45:57.203 [main] INFO  io.casperlabs.node.MetricsRuntime - Reporting metrics to Zipkin disabled.
19:45:57.207 [main] INFO  io.casperlabs.node.MetricsRuntime - Reporting metrics to JMX.
19:45:57.230 [main] INFO  kamon.metrics.SystemMetrics - Starting the Kamon(SystemMetrics) module
19:45:57.910 [main] INFO  io.casperlabs.node.api.Servers$ - HTTP server started on port 40403.
19:45:59.328 [main] INFO  i.c.casper.ValidatorIdentity$ - Validator identity: 1KzamFTtaBw9Or1VypuruBvjeLIy3oBSSfw75Sj3ZVw=
19:45:59.459 [main] INFO  i.c.casper.ValidatorIdentity$ - Validator identity: 1KzamFTtaBw9Or1VypuruBvjeLIy3oBSSfw75Sj3ZVw=
19:45:59.468 [main] INFO  i.c.node.casper.gossiping.package$ - Starting with validator identity d4acda9854ed681c3d3abd55ca9babb81be378b232de805249fc3be528f7655c
19:45:59.475 [main] INFO  i.c.node.casper.gossiping.package$ - Starting in default mode
19:45:59.709 [main] INFO  io.casperlabs.node.NodeRuntime - Starting node that will bootstrap from casperlabs://f8f4729cc394c26048e4c5c10c74f3e179a4741d@<IP>?protocol=40400&discovery=40404
19:45:59.727 [main] INFO  io.casperlabs.node.NodeRuntime - Listening for traffic on casperlabs://be468708898a626cc714b78d4d7897cc686e5c3a@<IP>?protocol=40400&discovery=40404.
19:46:01.664 [node-runner-17] INFO  i.c.node.casper.gossiping.package$ - Validating genesis-like block 0a54be59fa......
19:46:01.701 [node-runner-17] INFO  i.c.c.MultiParentCasperImpl$StatelessExecutor - Attempting to add Block with missing elements (0a54be59fa...) to the DAG.
19:46:02.575 [grpc-default-executor-1] WARN  i.c.blockstorage.FileDagStorage$ - Block 0a54be59fa3d2f112a459e0d3708822f46f7ae6820cf8df31274741ce8b80d4a validator is empty
19:46:02.651 [grpc-default-executor-1] INFO  i.c.c.MultiParentCasperImpl$StatelessExecutor - Added 0a54be59fa...
19:46:02.661 [node-runner-16] INFO  i.c.c.gossiping.GenesisApproverImpl - Downloaded Genesis candidate 0a54be59fa3d2f112a459e0d3708822f46f7ae6820cf8df31274741ce8b80d4a from bootstrap.
19:46:02.744 [node-runner-16] INFO  i.c.c.gossiping.GenesisApproverImpl - Added new approval; got 1 in total.
19:46:02.765 [node-runner-16] INFO  i.c.c.gossiping.GenesisApproverImpl - Transitioned to approved genesis state.
19:46:02.829 [node-runner-17] INFO  i.c.casper.ValidatorIdentity$ - Validator identity: 1KzamFTtaBw9Or1VypuruBvjeLIy3oBSSfw75Sj3ZVw=
19:46:02.916 [grpc-default-executor-1] INFO  i.c.node.casper.gossiping.package$ - Making the transition to block processing.
19:46:03.037 [node-runner-16] INFO  i.c.c.gossiping.GossipServiceServer - Received notification about 1 new blocks from casperlabs://f8f4729cc394c26048e4c5c10c74f3e179a4741d@<IP>?protocol=40400&discovery=40404.
19:46:04.695 [node-runner-17] INFO  i.c.node.casper.gossiping.package$ - Peers: 1
19:46:04.700 [node-runner-17] INFO  i.c.node.casper.gossiping.package$ - Connected to casperlabs://f8f4729cc394c26048e4c5c10c74f3e179a4741d@<IP>?protocol=40400&discovery=40404

# Note: -f flag will follow the log.  CTRL+C will exit or we can open a new terminal an continue to monitor the log.

And that's it! You've successfully joined a network! 


To start deploying to your node, see our docs here: https://github.com/CasperLabs/CasperLabs/blob/dev/docs/CONTRACTS.md
Note: Remember to change --host to the ip of your node in the above case.