“Hello Canton” with Docker Part 1

In this post, I’ll share a walkthrough of the Canton and Docker equivalent of “hello world”. Once Docker is installed, starting your own Canton ledger is incredibly simple:

This command pulls the latest Canton open source image from Docker Hub and creates a container running Canton. After a few seconds, the Canton console prompt will appear, and we can interact with our new ledger. As an example, we can see the status of our ledger by running “health.status”:

Here we can see that we have created one domain called “mydomain” and two participant nodes, termed “participant1” and “participant2”.

How did all of that happen and where was everything configured?

We’ll come to that. First of all, though, you may have noticed from the output above that our participants are not connected to our domain. Let’s use the Canton console to connect them:


Now, if we run “health.status” again we will see that the participants are connected to the domain.

As a quick aside, pressing “tab” in the Canton console gives autocomplete prompts, and appending .help to a command often yields useful information.

Next, let’s examine how we arrived at our Canton ledger configuration. The best place to start is to inspect the Docker container that we ran. First, exit the Canton console by typing “exit”. This takes us back to the host command line, and it will also terminate the container (since we were running in interactive mode). Of course, the connections that we made above will also be lost, since on the next run, our container will be re-created from the image.

Inspect the image as follows:

The three entries of interest are:

These entries in combination tell the container to start in the “/canton” directory with the command (don’t type this, as it won’t run on your Docker host):

The path to the config file in the container is “/canton/examples/01-simple-topology.conf”. To see that config file, simply run the container again, but this time, override the entrypoint to run a shell rather than Canton:

Now we have a command prompt on the container, we can take a look at the config file:


Now we’re able to see where the domain and the two participants are configured. As we’ve seen, this is a simple configuration, where everything is stored in memory. The memory storage is useful for learning and demos. For more information on the format of Canton configuration files, see the Canton documentation.

In the next post, we’ll connect the Daml Navigator to our ledger.