I am attempting to add this to export in my profile

export CLI ='docker-compose exec cardano-node sh -c "CARDANO_NODE_SOCKET_PATH=/ipc/node.socket cardano-cli"'

This command works with no issue from the command line docker-compose exec cardano-node sh -c "CARDANO_NODE_SOCKET_PATH=/ipc/node.socket cardano-cli"

I tried it placing it in quote a number of ways and I keep getting the following error

cardano-cli": -c: line 0: unexpected EOF while looking for matching `"' cardano-cli": -c: line 1: syntax error: unexpected end of file

What's the deal here?

1

There are 1 answers

1
David Maze On

docker-compose exec takes a -e option to set environment variables. If you use that option, you don't need the sh -c wrapper, since you are just running a simple command, and this removes a layer of quotes.

export CLI=`docker-compose exec -e CARDANO_NODE_SOCKET_PATH=/ipc/node.socket cardano-node cardano-cli`

docker-compose exec will also get the environment variables from the docker-compose.yml file, so if you declare the variables there

services:
  cardano-node:
    environment:
      - CARDANO_NODE_SOCKET_PATH=/ipc/node.socket

you don't have to repeat them in docker-compose exec at all

export CLI=`docker-compose exec cardano-node cardano-cli`