ElementsProject / lightning

Core Lightning — Lightning Network implementation focusing on spec compliance and performance
Other
2.81k stars 890 forks source link

Running bitcoin + lightning in Docker #5322

Closed dracorl closed 2 years ago

dracorl commented 2 years ago

Hello, I'm trying to run bitcoin and lightning in Docker.

I used this command for run Bitcoin Daemon: docker run -ti --name bitcoind_mainnet --network=bitcoin-net -v /datadrive/bitcoin/mainnet/bitcoind:/bitcoin/.bitcoin -p 8333:8333 -p 9735:9735 kylemanna/bitcoind

I checked bitcoin-cli with this command: docker exec -it bitcoind_mainnet bash

output:

root@cf3cc5ae5224:~# bitcoin-cli -getinfo
Chain: main
Blocks: 577751
Headers: 740975
Verification progress: ▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░ 56.3427%
Difficulty: 6704632680587.417

Network: in 0, out 10, total 10
Version: 230000
Time offset (s): -5
Proxies: n/a
Min tx relay fee rate (BTC/kvB): 0.00001000

Warnings:

I used this command for run Lightning: docker run -ti --name lightningd --network=bitcoin-net -v /datadrive/bitcoin/mainnet/bitcoind:/bitcoin/.bitcoin -v /datadrive/bitcoin/mainnet/lightningd:/root/.lightning elementsproject/lightningd --network=bitcoin --log-level=debug

and the output like this:

2022-06-15T22:36:39.611Z DEBUG   plugin-manager: started(8) /usr/local/bin/../libexec/c-lightning/plugins/autoclean
2022-06-15T22:36:39.615Z DEBUG   plugin-manager: started(9) /usr/local/bin/../libexec/c-lightning/plugins/bcli
2022-06-15T22:36:39.617Z DEBUG   plugin-manager: started(10) /usr/local/bin/../libexec/c-lightning/plugins/fetchinvoice
2022-06-15T22:36:39.620Z DEBUG   plugin-manager: started(11) /usr/local/bin/../libexec/c-lightning/plugins/funder
2022-06-15T22:36:39.623Z DEBUG   plugin-manager: started(12) /usr/local/bin/../libexec/c-lightning/plugins/topology
2022-06-15T22:36:39.634Z DEBUG   plugin-manager: started(13) /usr/local/bin/../libexec/c-lightning/plugins/keysend
2022-06-15T22:36:39.636Z DEBUG   plugin-manager: started(14) /usr/local/bin/../libexec/c-lightning/plugins/offers
2022-06-15T22:36:39.642Z DEBUG   plugin-manager: started(15) /usr/local/bin/../libexec/c-lightning/plugins/pay
2022-06-15T22:36:39.647Z DEBUG   plugin-manager: started(16) /usr/local/bin/../libexec/c-lightning/plugins/txprepare
2022-06-15T22:36:39.649Z DEBUG   plugin-manager: started(17) /usr/local/bin/../libexec/c-lightning/plugins/spenderp
2022-06-15T22:36:39.654Z DEBUG   plugin-manager: started(18) /usr/local/bin/../libexec/c-lightning/plugins/cln-grpc
2022-06-15T22:36:39.674Z DEBUG   lightningd: testing /usr/local/libexec/c-lightning/lightning_channeld
2022-06-15T22:36:39.689Z DEBUG   lightningd: testing /usr/local/libexec/c-lightning/lightning_closingd
2022-06-15T22:36:39.697Z DEBUG   lightningd: testing /usr/local/libexec/c-lightning/lightning_connectd
2022-06-15T22:36:39.705Z DEBUG   lightningd: testing /usr/local/libexec/c-lightning/lightning_gossipd
2022-06-15T22:36:39.714Z DEBUG   lightningd: testing /usr/local/libexec/c-lightning/lightning_hsmd
2022-06-15T22:36:39.722Z DEBUG   lightningd: testing /usr/local/libexec/c-lightning/lightning_onchaind
2022-06-15T22:36:39.731Z DEBUG   lightningd: testing /usr/local/libexec/c-lightning/lightning_openingd
2022-06-15T22:36:39.751Z DEBUG   hsmd: pid 29, msgfd 37
2022-06-15T22:36:39.790Z DEBUG   connectd: pid 30, msgfd 41
2022-06-15T22:36:39.790Z DEBUG   hsmd: new_client: 0
2022-06-15T22:36:39.907Z DEBUG   connectd: Created listener on [::]:9735
2022-06-15T22:36:39.907Z DEBUG   connectd: Failed to connect 10 socket: Cannot assign requested address
2022-06-15T22:36:39.907Z DEBUG   connectd: Created listener on 0.0.0.0:9735
2022-06-15T22:36:39.907Z DEBUG   connectd: REPLY WIRE_CONNECTD_INIT_REPLY with 0 fds
2022-06-15T22:36:39.907Z DEBUG   connectd: connectd_init_done

Could not connect to bitcoind using bitcoin-cli. Is bitcoind running?

Make sure you have bitcoind running and that bitcoin-cli is able to connect to bitcoind.

You can verify that your Bitcoin Core installation is ready for use by running:

    $ bitcoin-cli echo 'hello world'

2022-06-15T22:36:39.926Z **BROKEN** plugin-bcli: \nCould not connect to bitcoind using bitcoin-cli. Is bitcoind running?\n\nMake sure you have bitcoind running and that bitcoin-cli is able to connect to bitcoind.\n\nYou can verify that your Bitcoin Core installation is ready for use by running:\n\n    $ bitcoin-cli echo 'hello world'\n
2022-06-15T22:36:39.927Z INFO    plugin-bcli: Killing plugin: exited before we sent init
The Bitcoin backend died.

Could someone help me to understand the issue?

vincenzopalazzo commented 2 years ago

Difficult without know your docker file.

However, this is how I ran the integration testing inside some of my project that required the combo bitcoind + cln https://github.com/laanwj/rust-clightning-rpc/blob/master/Dockerfile

zerofeerouting commented 2 years ago

lightningd needs to be able to connect to your bitcoind.

If you run both on the same machine, make sure you tell CLN:

dracorl commented 2 years ago

in /bitcoin/.bitcoin/bitcoin.conf I added rpcallowip=172.18.0.3.

Also there is no config file in /root/.lightning so I created one and added these:

bitcoin-rpcuser=bitcoinrpc
bitcoin-rpcpassword=******
bitcoin-rpcconnect=172.18.0.2
bitcoin-rpcport=8332

I don't know if there is anything unnecessary but it is working now. Thank you very much for your answers