Bitcoin

json rpc – connect bitcoind and BTC RPC explorer in docker

I apologize if the question is not about Bitcoin, like Docker or RPC Explorer. My problem seems to be exposing the Bitcoin RPC correctly, but I’m hoping someone can shed light on where I’m going wrong.

I’m trying to run bitcoind and RPC Explorer in a Docker container, and so far bitcoind is running successfully and fully synced with the chain. But I can’t get the RPC connection to work in Explorer. To keep the setup as simple as possible, we want to pass all relevant environment variables to each container using docker compose, like this: Explorer runs, but cannot connect to RPC.

services:
  bitcoin:
    container_name: bitcoind
    user: 1000:100
    image: lncm/bitcoind:v27.0
    environment:
      BTC_DISABLEWALLET: 1
      BTC_SERVER: 1
      BTC_RPCUSER: $USER
      BTC_RPCPASSWORD: $PASS
      BTC_RPCBIND: 0.0.0.0
      BTC_RPCPORT: 8332
    volumes:
      - /TIMECHAIN:/data/.bitcoin
    restart: on-failure
    stop_grace_period: 15m30s
    ports:
      - "8333:8333"
      - "8332:8332"
      - "28332:28332"
      - "28333:28333"
    network_mode: host
  explorer:
    container_name: btc-rpc-explorer
    image: tyzbit/btc-rpc-explorer:latest
    user: 1000:100
    environment:
      BTCEXP_HOST: 0.0.0.0
      BTCEXP_PORT: 3002
      BTCEXP_BITCOIND_HOST: localhost
      BTCEXP_BITCOIND_PORT: 8332
      BTCEXP_BITCOIND_USER: $USER
      BTCEXP_BITCOIND_PASS: $PASS
      BTCEXP_SLOW_DEVICE_MODE: false
    restart: on-failure
    ports:
      - "3002:3002"
    network_mode: host

networks:
  default:
    driver: bridge

Related Articles

Back to top button