How To Run A Bootstrapped Corda Network On Docker

Senudajayalath
Coinmonks
6 min readJul 24, 2023

--

Tutorial on how to run an entire corda network on docker containers.

How cool would it be to set up your own corda network running on docker containers? In this tutorial I would guide you on how to do exactly that. While I was working on this project, I realized how most of the supporting online materials were outdated. In this article, I will guide you through the process of setting up the prerequisites required for the tutorial, providing the latest versions available at the time of writing, and offering insights on how to stay up-to-date with future releases.

I will also walk you through the step-by-step process of setting up a Corda network with five nodes, featuring the inclusion of two notaries.

Photo by Shubham Dhage on Unsplash

Prerequisites

  1. Network Bootstrapper tool — You can download the required version from this link. Keep in mind to download the jar file of the selected bootstrapper tool version. For this tutorial I will be using V4.10 which can be found here.
  2. Corda Docker Image — The link to the latest docker image can be found from the Corda dcoumentation, or from Corda Docker Hub. (Note- If you are using the Corda documentation link, I have attached the documentation of Corda V4.10 -enterprise edition. If you are using some other version/edition alter the link accordingly). I will be using corda/community:4.10-zulu-openjdk8 for this tutorial.
  3. Java 8 — Double check if path to Java 8 is set as $JAVA_HOME
  4. Docker Compose

I strongly recommend using identical versions of the Corda Docker image and the Network Bootstrapper. Maintaining version consistency will help ensure a smooth and error-free setup of your Corda network.

Initial Setup

Let’s kickstart the process by creating a dedicated folder and placing the bootstrap jar file inside it. This folder will serve as the central workspace for this tutorial, and all subsequent files will be generated and stored here. This approach will keep our project organized and make it easier to follow the tutorial steps.
Then we need to create some artifacts (node certificates and network-parameters) for the Corda network. These will be generated by running the network bootstrap jar file. To do that first we need to create node.conf files for each node.(i.e for notaries and general nodes)

This is what a sample node.conf file of a general node looks like

devMode=true
myLegalName="O=BankA,L=London,C=GB"
p2pAddress="banka:10200"
rpcSettings {
address="0.0.0.0:10201"
adminAddress="0.0.0.0:10202"
}
security {
authService {
dataSource {
type=INMEMORY
users=[
{
password=test
permissions=[
ALL
]
user=user1
}
]
}
}
}
sshd {
port = 2222
}

This is what a sample node.conf file of a notary looks like

devMode=true
myLegalName="O=NotaryA,L=London,C=GB"
notary {
validating=false
}
p2pAddress="notarya:10200"
rpcSettings {
address="0.0.0.0:10201"
adminAddress="0.0.0.0:10202"
}

The official Corda docker image exposes the ports 10200, 10201 and 10202. Do not change them in the node.conf file.

Make sure you listen to 0.0.0.0 not 127.0.0.1 or localhost , since those will be localhost for the container.

Running the Bootstrapper

Now once we have the node.conf ready for all our nodes we can run the network-bootstrapper tool. To run the bootstrapper tool, place the bootstrapper jar alongside the node.conf files and run the bootstrapper jar using the java -jar <bootstrapper-jar-file-name> command. It should generate a lot of files/folders as shown below.

The files/folders in the root directory
Files/folders inside BankA folder

Now this is a lot of files. We are not going to need all the files that got generated, so let’s do some cleanup. All we need is the node.conf file, the node certificates and the network-paramaters. Below is how the nodes folders look after the removal of all unnecessary files. Notice that we have moved the network-parameters file to a shared folder.

All the network-parameter files generated inside their respective folders are identical to each other. Therefore, you can move any of the network-parameters files from a generated node folder(i.e bankA folder) to the shared directory.

We need one final thing, a CorDapp. No, I am not going to build one here, but I can use one from the Corda-samples repo.

But where do we place this CorDapp? Just create another cordapps folder inside the shared folder and drop the CorDapps in. We will configure the Corda docker containers to look for CorDapps in this folder.

Configuring the Docker Compose file

Now we have all we need to define the docker container. As mentioned earlier, we are going to use docker compose. For each container, we need to define a service in the docker-compose.yaml file. Let’s see how it looks for Bank A and Notary A.

notarya:
image: corda/community:4.10-zulu-openjdk8
container_name: notaryb
user: root
ports:
- "10004:10201"
volumes:
- ./notaryA/node.conf:/etc/corda/node.conf
- ./notaryA/node.conf:/opt/corda/node.conf
- ./notaryA/certificates:/opt/corda/certificates
- ./notaryA/persistence:/opt/corda/persistence
- ./notaryA/corda.jar:/opt/corda/corda.jar
- ./notaryA/logs:/opt/corda/logs
- ./shared/cordapps:/opt/corda/cordapps
- ./shared/node-infos:/opt/corda/additional-node-infos
- ./shared/network-parameters:/opt/corda/network-parameters
command: >
bash -c "cd /opt/corda && java -jar corda.jar run-migration-scripts --core-schemas --app-schemas && java -jar corda.jar"
banka:
image: corda/community:4.10-zulu-openjdk8
container_name: banka
user: root
ports:
- "10006:10201"
- "2001:2222"
volumes:
- ./bankA/node.conf:/etc/corda/node.conf
- ./bankA/node.conf:/opt/corda/node.conf
- ./bankA/certificates:/opt/corda/certificates
- ./bankA/persistence:/opt/corda/persistence
- ./bankA/corda.jar:/opt/corda/corda.jar
- ./bankA/logs:/opt/corda/logs
- ./shared/cordapps:/opt/corda/cordapps
- ./shared/node-infos:/opt/corda/additional-node-infos
- ./shared/network-parameters:/opt/corda/network-parameters
command: >
bash -c "cd /opt/corda && java -jar corda.jar run-migration-scripts --core-schemas --app-schemas && java -jar corda.jar"

As shown above your docker-compose file should have a service for each of the nodes you want in your network.

Note that we also mount an empty folder called node-infos from the shared directory. As the node spins-up inside the container it places its node-info file in this shared folder, so that its discoverable by other nodes in the network. So this serves as a network map.

To spin up the containers, just use the command docker-compose up from the root directory. If all goes well you will see something like the following for each node you have configured.

Connecting to the Node

We do not get the CRaSH shell as we normally get when running the node directly in the host machine. So, how do we connect to the node? There are two ways to that:

  • Using a client. (You don’t have to build one — Try node-explorer)
  • Using ssh: ssh -p [portNumber] [host] -l [user]

Possible Errors

These are some of the errors I got and the solutions for them,

  1. Incompatible database schema version detected, please run schema migration scripts (node with sub-command run-migration-scripts). Reason: There are 110 outstanding database changes that need to be run.
    Solution — I have added a command for each service in the docker-compose file to overcome this
  2. Required platform version is less than the minimum platform version error
    Solution — Use the same same version of bootstrapper tool and docker image

This way you can setup your own boostrapped corda network very easily. If you do encounter errors let me know in the comment section.

Happy Coding!!

Resources

  1. Network Bootstrapper Tool — https://software.r3.com/ui/native/corda/net/corda/corda-tools-network-bootstrapper/
  2. Corda Documentation — https://docs.r3.com/en/platform/corda/4.10/enterprise/docker-image.html
  3. Corda Docker Hub — https://hub.docker.com/u/corda

--

--