I have a bitcoin docker container kylemanna/bitcoind with the following bitcoin.conf file:
disablewallet=1
printtoconsole=1
server=1
txindex=1
rpcport=8332
testnet=1
rpcauth=jfjobidon:235f8…
when I don’t use containers, I can connect to bitcoind and make requests. When I put my micro-services in containers, I can no longer connect to bitcoind.
my docker-compose file:
version: “3.6”
services:
bitcoind:
image: kylemanna/bitcoind
ports:
- “8332:8332”
deploy:
placement:
constraints: [node.role == manager]
volumes:
- bitcoind-data:/bitcoin
watchbcbtc:
image: eventmonitor_watchbcbtc
deploy:
replicas: 1
restart_policy:
condition: on-failure
depends_on:
- redis
- mongo
redis:
image: redis:4.0
command: redis-server --appendonly yes
ports:
- “6379:6379”
command: redis-server --appendonly yes
volumes:
- redis-data:/data/
mongo:
image: mongo:3.4
ports:
- “27017:27017”
deploy:
placement:
constraints: [node.role == manager]
volumes:
- mongo-data:/data/db
- mongo-config:/data/configdbvolumes:
bitcoind-data:
mongo-data:
mongo-config:
redis-data:
in my script:
const clientBTC = new bitcoin.Client({
host: ‘bitcoin’,
port: 8332,
user: ‘jfjobidon’,
pass: ‘LwTE…’
});
I can go inside the container and make requests on the blockchain (ex: bitcoin-cli getblockcount)
But I cannot connect from another container (watchbcbtc): I have the following error:
Error: connect ECONNREFUSED 127.0.0.1:8332
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1189:14)
I removed the network command in my docker-compose.yml file for testing purpose…