ruimarinho / docker-bitcoin-core

A bitcoin-core docker image
https://hub.docker.com/r/ruimarinho/bitcoin-core/
MIT License
370 stars 208 forks source link

I can't connect with bitcoin-cli or rpc client. #95

Closed educob closed 4 years ago

educob commented 4 years ago

Hi.

I have created the container with:

docker run --name testnetnode -d \
  -p 18332:18332 \
  -p 18333:18333 \
  ruimarinho/bitcoin-core \
  -testnet=1 \
  -debug=1 \
  -server=1 \
  -rpcbind=127.0.0.1 \
  -rpcallowip=127.0.0.1 \
  -rest=1 \
  -txindex=1 \
  -zmqpubhashblock=tcp://127.0.0.1:18110 \
  -zmqpubrawtx=tcp://127.0.0.1:18111 \
  -zmqpubrawblock=tcp://127.0.0.1:18112 \
-datadir=/media/r2d2/ssd_2/.bitcoin/testnet \
-rpcauth='testnet:xxxx'

I can connect with docker successfully: docker exec testnetnode bitcoin-cli -testnet -rpcport=18332 -rpcuser=testnet --rpcpassword=xxx getblockchaininfo

But bitcoin-cli doesn't work: bitcoin-cli -rpcuser=testnet -rpcport=18332 -rpcpassword=xxx getblockchaininfo

Gives error:

error: Could not connect to the server 127.0.0.1:18332

Make sure the bitcoind server is running and that you are connecting to the correct RPC port.

From my rpc client I get also get an error: Error: socket hang up

Another thing I don't understand is that docker ps shows that the contrainer is reserving ports 8332-8333 which are mainnet's and port 18443:18444 which are regtest's. 1440c49ed036 ruimarinho/bitcoin-core "/entrypoint.sh -tes…" 28 minutes ago Up 28 minutes 8332-8333/tcp, 18443-18444/tcp, 0.0.0.0:18332-18333->18332-18333/tcp testnetnode

ruimarinho commented 4 years ago

Where are you running bitcoin-cli? You might need to add the docker network subnet to the allowed IP range.

Another thing I don't understand is that docker ps shows that the container is reserving ports 8332-8333 which are mainnet's and port 18443:18444 which are regtest's.

That's simply presentational as indicated by https://github.com/ruimarinho/docker-bitcoin-core/blob/master/0.20/Dockerfile#L43. Unless you see an IP (usually 0.0.0.0), the port is not mapped to the host.

educob commented 4 years ago

Thanks. I'll take a look.