2

I have the following problem:

I am running several containers via docker-compose consisting of a cardano-node-container, cardano-db-sync-container (including a postgres-container) AND another container which wants to access the cardano-cli in order to submit transactions. I can't get the cardano-cli command working in the container I want to submit transactions from: "cardano-cli: command not found”. I am out of ideas and not very familiar with unix-sockets.

This is my docker-compose-file (irrelevant information replaced with (...)):

version: "3.4"
services:

  homeassistant:
    image: homeassistant/home-assistant:2022.9
    (...)

  CONTAINER-TRYING-TO-ACCESS-CARDANO-CLI:
    image: (...)
    restart: always
    environment:
      - CARDANO_NODE_SOCKET_PATH=/ipc/node.socket
    volumes:
      - "node-ipc:/ipc"
    logging: (...)

  cardano-node:
    image: inputoutput/cardano-node:1.35.4
    restart: always
    environment:
      - NETWORK=mainnet
      - CARDANO_NODE_SOCKET_PATH=/ipc/node.socket
    volumes:
      - "/volume1/docker/cardano/ada-node:/data"
      - "node-ipc:/ipc"
    healthcheck (...)
    logging (...)

  cardano-db-sync:
    image: inputoutput/cardano-db-sync:13.0.5-extra-args
    restart: always
    environment:
      - NETWORK=mainnet
      - POSTGRES_HOST=cardano-postgres-db
      - POSTGRES_PORT=5432
      - RESTORE_RECREATE_DB=N
    depends_on:
      cardano-node:
        condition: service_healthy
      cardano-postgres-db:
        condition: service_healthy
    secrets:
      - postgres_password
      - postgres_user
      - postgres_db
    volumes:
      - "/volume1/docker/cardano/db-sync-data:/var/lib/cexplorer"
      - "node-ipc:/node-ipc"
    logging: (...)


  cardano-postgres-db:
    image: postgres:11.5-alpine
    restart: on-failure
    environment:
      - POSTGRES_LOGGING=true
      - POSTGRES_DB_FILE=/run/secrets/postgres_db
      - POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
      - POSTGRES_USER_FILE=/run/secrets/postgres_user
    secrets:
      - postgres_password
      - postgres_user
      - postgres_db
    volumes:
      - "/volume1/docker/cardano/db-sync-postgres-db:/var/lib/postgresql/data"
    healthcheck: (...)
    logging: (...)

secrets:
  postgres_db:
    file: ./config/secrets/postgres_db
  postgres_password:
    file: ./config/secrets/postgres_password
  postgres_user:
    file: ./config/secrets/postgres_user

volumes:
  node-ipc:

When I get into the containers bash that wants to access cardano-cli (CONTAINER-TRYING-TO-ACCESS-CARDANO-CLI) I can see, that there is the node.socket file at the defined /ipc/ folder.

Now I do not know what else to do :-/ I tried playing around with socat but couldn't figure out how to use the node-socket in order to use the cardano-cli via bash. The cardano-node is fully synced and cardano-db-sync is also working as expected. I can use cardano-cli inside the cardano-node container, but not from others.

The dirties version I can think of to accomplish this, would be installing ssh inside the cardano-node container and access the cli from the other container via sshing into the node. But this would be my last resort if you do not have any ideas for using the cli via the socket :confused:

Edit: Okay found a solution :) The base of my "CONTAINER-TRYING-TO-ACCESS-CARDANO-CLI"-container is node:17-alpine.

I am now pulling the hydra-binaries from https://github.com/input-output-hk/cardano-node/releases, unpacking and placing them inside my /usr/local/bin folder. Now I am able to use the cli from bash :D

This is my edited Dockerfile:

FROM node:17-alpine as node


RUN apk add curl
RUN apk add tar

# dl cardano cli-binary 1.35.4
WORKDIR /dl-bin
RUN curl https://hydra.iohk.io/build/21343721/download/1/cardano-node-1.35.4-linux.tar.gz -o cardano-node.tar.gz
RUN tar -xzf cardano-node.tar.gz && rm cardano-node.tar.gz
RUN cp -r /dl-bin/. /usr/local/bin
WORKDIR /
RUN rm -rf /dl-bin
# end dl cardano cli-binary 1.35.4

(...)

1 Answer 1

1

That means that container CONTAINER-TRYING-TO-ACCESS-CARDANO-CLI do not have binary cardano-cli inside(basically there are no such file) or cardano-cli is there but it is in location what is not inside path of that container, but I would guess it is a first. So this is nothing to do with /ipc/node.socket.

If that container is in docker hub, please let me know which I will try to troubleshoot further.

3
  • Hey, thanks for the response! Indeed, the binaries are not installed, because I thought I can access them through the node.socket. Its a custom image, so I guess I need to install the cli there inside? I'll check some tutorials on how to install the ci without bloating the image too much :) After that I guess I can point cardano-cli to the node.socket (as I already do via the env-var) and it all will work?
    – Pete22
    Nov 20, 2022 at 17:35
  • yes, should work. Seems you made it work! Glad I was able to help. Cheers!
    – os11k
    Nov 21, 2022 at 8:56
  • Yep, I got it to work :) I updated my post with my solution. Thanks again!
    – Pete22
    Nov 21, 2022 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.