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
(...)