Communication with cardano-cli from a Docker container

Can anyone help me with something, I’m trying to run a web server over the cardano-node docker image. I have some solutions in mind but I would like to have some feedback from you.

Approach # 1

Build a new image over the cardano-node docker image that install node and runs my server code.

My questions around this are:

  • Where can I find the cardano-node Dockerfile? I need to know what is already set up and what is the underlying Linux distro.
  • Related to the previous one, how can I install Node over the cardano-node image? I have tried multiple mechanisms like apt-get and nothing works.

Approach # 2

Create my web server in a different docker image and make the container communicate with the cardano-node container. Questions: - How can I communicate my webserver container with the cardano-node container so I can run the cardano-cli commands?

You would want to extend an existing docker image to get access to cardano-cli. Have a look at the incubator project for the cardano-node docker stuff. The base image is debian

1 Like

I have been creating a Dockerfile based on yours :slight_smile: !

I didn’t use your image directly because I noticed that you are adding more tools than I need.

But I have been struggling to understand your build setup.

Thanks for the replay. I’ll continue studying your project.

Thanks for the flowers

What is it that you don’t understand? Can you not simply do …

FROM nessusio/cardano-node:1.29.0

... [your stuff]

Yeah, end up doing that, it is working like charm.

I was just trying to light up the image, but I think that we the cardano-node that ship had already sailed.

Thanks for the follow-up!

The cli communicates with the node via the IPC socket. If the node exposes the socket through a volume like this …


… another container that references the same volume would only need to have the cli binary (and your stuff) i.e. your stuff does not have to run in the same container as the node


Oh nice, I was confused about how that would work!

Thank you!

So basically I would only need to bundle the CLI in my custom Docker Image and I could use the official Cardano Node image in a separate container.

1 Like

Yes, that should work. I have a some TCL wrapper around the CLI that drives my Plutus contracts in that way.


Now the oficial IOHK docker image for the cardano node has also the CLI.

To start the cardano node:

docker run --name=relay -p 3001:3001 -v node-data:/opt/cardano/data -v node-ipc:/opt/cardano/ipc inputoutput/cardano-node run

To execute a cli command to query utxos just to test that communication with the node works (I dont know well the cli):

docker run  -v node-data:/opt/cardano/data -v node-ipc:/opt/cardano/ipc inputoutput/cardano-node cli query utxo --whole-utxo  --testnet-magic 1