Post
Topic
Board Development & Technical Discussion
Topic OP
How to connect docker container to bitcoin node?
by
Exchangman
on 14/10/2022, 08:43:23 UTC
I have a python script inside docker container and a bitcoin node outside of docker in my local machine , this is my bitcoin.conf information

Code:
rpcuser=testuser
rpcpassword=testpassword
testnet=1
prune=550
server=1
[test]
rpcallowip=0.0.0.0/0
rpcport=8332
bind=127.0.0.1
minconf=1

and this is my docker compose conf file



Code:
app:
build:
  context: .
restart: always
volumes:
  - .:/app
extra_hosts:
  - "host.docker.internal:host-gateway"

then in my python script i'm trying to connect to the bitcoin node using this:

connection_url="http://%s:%s@localhost:8332/wallet/testwallet"
credentials=('testuser','testpassword')
rpc_connection = AuthServiceProxy(connection_url % credentials)
rpc_connection.getnewaddress()

when I make call to this script I get this error in return [Errno 111] Connection refused

Ps: when I run the same script outside of docker container it works fine Any solutions?? ++ is it safe to run the node and connect to it using a script like this? locally?