# Communication with cardano-cli from a Docker container

**URL:** <https://forum.cardano.org/t/communication-with-cardano-cli-from-a-docker-container/76843>\
**Category:** Misc Dev Talk\
**Created:** [27 September 2021 18:07 UTC](https://forum.cardano.org/t/communication-with-cardano-cli-from-a-docker-container/76843 "2021-09-27T18:07:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nacho\_vazquez](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/nacho_vazquez/32/43500_2.png) [@nacho\_vazquez](https://forum.cardano.org/u/nacho_vazquez)\
**Post date:** [27 September 2021 18:07 UTC](https://forum.cardano.org/t/communication-with-cardano-cli-from-a-docker-container/76843/1 "2021-09-27T18:07:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![tomdx](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/tomdx/32/44498_2.png) [@tomdx](https://forum.cardano.org/u/tomdx)\
**Post date:** [28 September 2021 19:28 UTC](https://forum.cardano.org/t/communication-with-cardano-cli-from-a-docker-container/76843/2 "2021-09-28T19:28:00Z")

</div>

You would want to extend an existing docker image to get access to cardano-cli. Have a look at the [incubator project](https://github.com/tdiesler/nessus-cardano) for the cardano-node docker stuff. The [base image](https://github.com/tdiesler/nessus-cardano/tree/main/nix/docker/baseImage) is debian

---

<div class="post-metadata">

**Author:** ![nacho\_vazquez](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/nacho_vazquez/32/43500_2.png) [@nacho\_vazquez](https://forum.cardano.org/u/nacho_vazquez)\
**Post date:** [28 September 2021 20:33 UTC](https://forum.cardano.org/t/communication-with-cardano-cli-from-a-docker-container/76843/3 "2021-09-28T20:33:09Z")

</div>

I have been creating a Dockerfile based on yours 🙂 !

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.

---

<div class="post-metadata">

**Author:** ![tomdx](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/tomdx/32/44498_2.png) [@tomdx](https://forum.cardano.org/u/tomdx)\
**Post date:** [29 September 2021 05:36 UTC](https://forum.cardano.org/t/communication-with-cardano-cli-from-a-docker-container/76843/4 "2021-09-29T05:36:18Z")

</div>

> [@nacho\_vazquez](#):
>
> I have been creating a Dockerfile based on yours

Thanks for the flowers

> [@nacho\_vazquez](#):
>
> But I have been struggling to understand your build setup.

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

```auto
FROM nessusio/cardano-node:1.29.0

... [your stuff]

```

---

<div class="post-metadata">

**Author:** ![nacho\_vazquez](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/nacho_vazquez/32/43500_2.png) [@nacho\_vazquez](https://forum.cardano.org/u/nacho_vazquez)\
**Post date:** [30 September 2021 02:07 UTC](https://forum.cardano.org/t/communication-with-cardano-cli-from-a-docker-container/76843/5 "2021-09-30T02:07:56Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![tomdx](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/tomdx/32/44498_2.png) [@tomdx](https://forum.cardano.org/u/tomdx)\
**Post date:** [30 September 2021 18:27 UTC](https://forum.cardano.org/t/communication-with-cardano-cli-from-a-docker-container/76843/6 "2021-09-30T18:27:46Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex023/uploads/cardano/original/3X/f/e/fe3ec071c42d2cccbdaf1c91d47d1820dd2c8772.png)

… 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

---

<div class="post-metadata">

**Author:** ![nacho\_vazquez](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/nacho_vazquez/32/43500_2.png) [@nacho\_vazquez](https://forum.cardano.org/u/nacho_vazquez)\
**Post date:** [2 October 2021 17:34 UTC](https://forum.cardano.org/t/communication-with-cardano-cli-from-a-docker-container/76843/7 "2021-10-02T17:34:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tomdx](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/tomdx/32/44498_2.png) [@tomdx](https://forum.cardano.org/u/tomdx)\
**Post date:** [2 October 2021 20:34 UTC](https://forum.cardano.org/t/communication-with-cardano-cli-from-a-docker-container/76843/8 "2021-10-02T20:34:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Alberto\_Gomez\_Corona](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/alberto_gomez_corona/32/25741_2.png) [@Alberto\_Gomez\_Corona](https://forum.cardano.org/u/Alberto_Gomez_Corona)\
**Post date:** [5 November 2021 10:22 UTC](https://forum.cardano.org/t/communication-with-cardano-cli-from-a-docker-container/76843/9 "2021-11-05T10:22:26Z")

</div>

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
```
