I am trying to execute a command inside my mongodb docker container. From my linux command prompt it is pretty easy and works when I do this
docker exec -it d886e775dfad mongo --eval 'rs.isMaster()'
The above tells me to go to a container and execute the command
"mongo --eval 'rs.isMaster()' - This tells mongo to take rs.isMaster() as an input and execute it. This works and gives me the output.
Since I am trying to automate this via bash script, I did this
cmd="mongo --eval 'rs.isMaster()"
And then tried executing like this
docker -H $node2 exec d886e775dfad "$cmd"
But I guess somehow docker thinks that now the binary file inside the container is not mongo or sth else and it gives me the following error:
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"mongo --eval 'rs.isMaster()'\": executable file not found in $PATH"