Skip to content

Commit a4a149b

Browse files
committed
docs(docker): update README for improved clarity and accuracy
1 parent eea4840 commit a4a149b

File tree

4 files changed

+37
-97
lines changed

4 files changed

+37
-97
lines changed

docker/README.md

Lines changed: 19 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
This document is written for people who are eager to do something with
2-
the Lightning Network Daemon (`lnd`). This folder uses `docker-compose` to
3-
package `lnd` and `btcd` together to make deploying the two daemons as easy as
4-
typing a few commands. All configuration between `lnd` and `btcd` are handled
5-
automatically by their `docker-compose` config file.
1+
This document is intended for those looking to get started with
2+
the Lightning Network Daemon (lnd). This folder uses docker to package lnd and
3+
btcd together, making the deployment of both daemons as simple as running a
4+
few commands. All configuration between lnd and btcd is handled automatically
5+
by the docker-compose.yml file
66

77
### Prerequisites
88
Name | Version
99
--------|---------
10-
docker-compose | 1.9.0
11-
docker | 1.13.0
10+
docker | 20.10.13+
1211

1312
### Table of content
1413
* [Create lightning network cluster](#create-lightning-network-cluster)
15-
* [Connect to faucet lightning node](#connect-to-faucet-lightning-node)
1614
* [Building standalone docker images](#building-standalone-docker-images)
1715
* [Using bitcoind version](#using-bitcoind-version)
1816
* [Start Bitcoin Node with bitcoind using Docker Compose](#start-bitcoin-node-with-bitcoind-using-docker-compose)
@@ -30,10 +28,6 @@ possible to spin up an arbitrary number of `lnd` instances within containers to
3028
create a mini development cluster. All state is saved between instances using a
3129
shared volume.
3230

33-
Current workflow is big because we recreate the whole network by ourselves,
34-
next versions will use the started `btcd` bitcoin node in `testnet` and
35-
`faucet` wallet from which you will get the bitcoins.
36-
3731
In the workflow below, we describe the steps required to recreate the following
3832
topology, and send a payment from `Alice` to `Bob`.
3933
```text
@@ -62,6 +56,11 @@ topology, and send a payment from `Alice` to `Bob`.
6256
* Close the channel between `Alice` and `Bob`.
6357
* Check that on-chain `Bob` balance was changed.
6458

59+
> [!IMPORTANT]
60+
> **Prerequisites:** This guide assumes you have **Docker** installed. If not, please follow the [official Docker installation guide](https://docs.docker.com/get-docker/).
61+
>
62+
>All commands should be executed from the `lnd/docker/` directory. Depending on your system's configuration, you may need to prefix **docker** commands with **sudo**. For `Linux` users, we highly recommend following the official [Docker documentation to manage Docker as a non-root](https://docs.docker.com/engine/install/linux-postinstall/) user, which allows you to run commands without sudo safely
63+
6564
Start `btcd`, and then create an address for `Alice` that we'll directly mine
6665
bitcoin into.
6766
```shell
@@ -73,11 +72,11 @@ $ docker volume create simnet_lnd_alice
7372
$ docker volume create simnet_lnd_bob
7473

7574
# Run the "Alice" container and log into it:
76-
$ docker-compose run -d --name alice --volume simnet_lnd_alice:/root/.lnd lnd
77-
$ docker exec -i -t alice bash
75+
$ docker compose run -d --name alice --volume simnet_lnd_alice:/root/.lnd lnd
76+
$ docker exec -it alice bash
7877

79-
# Generate a new backward compatible nested p2sh address for Alice:
80-
alice $ lncli --network=simnet newaddress np2wkh
78+
# Generate a new native SegWit (Bech32) address for Alice:
79+
alice $ lncli --network=simnet newaddress p2wkh
8180

8281
# Recreate "btcd" node and set Alice's address as mining address:
8382
$ export MINING_ADDRESS=<alice_address>
@@ -86,9 +85,6 @@ $ docker-compose up -d btcd
8685
# Generate 400 blocks (we need at least "100 >=" blocks because of coinbase
8786
# block maturity and "300 ~=" in order to activate segwit):
8887
$ docker exec -it btcd /start-btcctl.sh generate 400
89-
90-
# Check that segwit is active:
91-
$ docker exec -it btcd /start-btcctl.sh getblockchaininfo | grep -A 1 segwit
9288
```
9389

9490
Check `Alice` balance:
@@ -100,8 +96,8 @@ Connect `Bob` node to `Alice` node.
10096

10197
```shell
10298
# Run "Bob" node and log into it:
103-
$ docker-compose run -d --name bob --volume simnet_lnd_bob:/root/.lnd lnd
104-
$ docker exec -i -t bob bash
99+
$ docker compose run -d --name bob --volume simnet_lnd_bob:/root/.lnd lnd
100+
$ docker exec -it bob bash
105101

106102
# Get the identity pubkey of "Bob" node:
107103
bob $ lncli --network=simnet getinfo
@@ -267,66 +263,6 @@ bob $ lncli --network=simnet walletbalance
267263
}
268264
```
269265

270-
### Connect to faucet lightning node
271-
In order to be more confident with `lnd` commands I suggest you to try
272-
to create a mini lightning network cluster ([Create lightning network cluster](#create-lightning-network-cluster)).
273-
274-
In this section we will try to connect our node to the faucet/hub node
275-
which we will create a channel with and send some amount of
276-
bitcoins. The schema will be following:
277-
278-
```text
279-
+ ----- + + ------ + (1) + --- +
280-
| Alice | <--- channel ---> | Faucet | <--- channel ---> | Bob |
281-
+ ----- + + ------ + + --- +
282-
| | |
283-
| | | <--- (2)
284-
+ - - - - - - - - - - - - - + - - - - - - - - - - - - - +
285-
|
286-
+ --------------- +
287-
| Bitcoin network | <--- (3)
288-
+ --------------- +
289-
290-
291-
(1) You may connect an additional node "Bob" and make the multihop
292-
payment Alice->Faucet->Bob
293-
294-
(2) "Faucet", "Alice" and "Bob" are the lightning network daemons which
295-
create channels to interact with each other using the Bitcoin network
296-
as source of truth.
297-
298-
(3) In current scenario "Alice" and "Faucet" lightning network nodes
299-
connect to different Bitcoin nodes. If you decide to connect "Bob"
300-
to "Faucet" then the already created "btcd" node would be sufficient.
301-
```
302-
303-
First you need to run `btcd` node in `testnet` and wait for it to be
304-
synced with test network (`May the Force and Patience be with you`).
305-
```shell
306-
# Init bitcoin network env variable:
307-
$ NETWORK="testnet" docker-compose up
308-
```
309-
310-
After `btcd` synced, connect `Alice` to the `Faucet` node.
311-
312-
The `Faucet` node address can be found at the [Faucet Lightning Community webpage](https://faucet.lightning.community).
313-
314-
```shell
315-
# Run "Alice" container and log into it:
316-
$ docker-compose run -d --name alice lnd_btc; docker exec -i -t "alice" bash
317-
318-
# Connect "Alice" to the "Faucet" node:
319-
alice $ lncli --network=testnet connect <faucet_identity_address>@<faucet_host>
320-
```
321-
322-
After a connection is achieved, the `Faucet` node should create the channel
323-
and send some amount of bitcoins to `Alice`.
324-
325-
**What you may do next?:**
326-
- Send some amount to `Faucet` node back.
327-
- Connect `Bob` node to the `Faucet` and make multihop payment (`Alice->Faucet->Bob`)
328-
- Close channel with `Faucet` and check the onchain balance.
329-
330266
### Building standalone docker images
331267

332268
Instructions on how to build standalone docker images (for development or
@@ -339,7 +275,7 @@ If you are using the bitcoind version of the compose file i.e. `docker-compose-b
339275
#### Start Bitcoin Node with bitcoind using Docker Compose
340276
To launch the Bitcoin node using bitcoind in the regtest network using Docker Compose, use the following command:
341277
```shell
342-
$ NETWORK="regtest" docker-compose -f docker-compose-bitcoind.yml up
278+
$ NETWORK="regtest" docker compose -f docker-compose-bitcoind.yml up
343279
```
344280

345281
#### Generating RPCAUTH
@@ -377,5 +313,5 @@ Note: The address `2N1NQzFjCy1NnpAH3cT4h4GoByrAAkiH7zu` is just a random example
377313

378314
* How to see `alice` | `bob` | `btcd` | `lnd` | `bitcoind` logs?
379315
```shell
380-
$ docker-compose logs <alice|bob|btcd|lnd|bitcoind>
316+
$ docker compose logs <alice|bob|btcd|lnd|bitcoind>
381317
```

docker/btcd/Dockerfile

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# If you change this please also update GO_VERSION in Makefile (then run
22
# `make lint` to see where else it needs to be updated as well).
3-
FROM golang:1.25.3-alpine as builder
3+
ARG GO_VERSION=1.25.3
4+
FROM golang:${GO_VERSION}-alpine AS builder
45

56
LABEL maintainer="Olaoluwa Osuntokun <laolu@lightning.engineering>"
67

@@ -10,15 +11,15 @@ RUN apk add --no-cache git gcc musl-dev
1011
WORKDIR $GOPATH/src/github.com/btcsuite/btcd
1112

1213
# Pin down btcd to a version that we know works with lnd.
13-
ARG BTCD_VERSION=v0.23.4
14+
ARG BTCD_VERSION=v0.25.0
1415

1516
# Grab and install the latest version of of btcd and all related dependencies.
1617
RUN git clone https://github.com/btcsuite/btcd.git . \
1718
&& git checkout $BTCD_VERSION \
1819
&& go install -v . ./cmd/...
1920

2021
# Start a new image
21-
FROM alpine as final
22+
FROM alpine:3.22 AS final
2223

2324
# Expose mainnet ports (server, rpc)
2425
EXPOSE 8333 8334
@@ -29,7 +30,7 @@ EXPOSE 18333 18334
2930
# Expose simnet ports (server, rpc)
3031
EXPOSE 18555 18556
3132

32-
# Expose segnet ports (server, rpc)
33+
# Expose signet ports (server, rpc)
3334
EXPOSE 28901 28902
3435

3536
# Copy the compiled binaries from the builder image.
@@ -45,13 +46,13 @@ COPY "start-btcd.sh" .
4546
RUN apk add --no-cache \
4647
bash \
4748
ca-certificates \
48-
&& mkdir "/rpc" "/root/.btcd" "/root/.btcctl" \
49-
&& touch "/root/.btcd/btcd.conf" \
50-
&& chmod +x start-btcctl.sh \
51-
&& chmod +x start-btcd.sh \
52-
# Manually generate certificate and add all domains, it is needed to connect
53-
# "btcctl" and "lnd" to "btcd" over docker links.
54-
&& "/bin/gencerts" --host="*" --directory="/rpc" --force
49+
&& mkdir "/rpc" "/root/.btcd" "/root/.btcctl" \
50+
&& touch "/root/.btcd/btcd.conf" \
51+
&& chmod +x start-btcctl.sh \
52+
&& chmod +x start-btcd.sh \
53+
# Manually generate certificate and add all domains, it is needed to connect
54+
# "btcctl" and "lnd" to "btcd" over docker links.
55+
&& "/bin/gencerts" --host="*" --host="blockchain" --directory="/rpc" --force
5556

5657
# Create a volume to house pregenerated RPC credentials. This will be
5758
# shared with any lnd, btcctl containers so they can securely query btcd's RPC
@@ -60,3 +61,7 @@ RUN apk add --no-cache \
6061
# Otherwise manually generated certificate will be overridden with shared
6162
# mounted volume! For more info read dockerfile "VOLUME" documentation.
6263
VOLUME ["/rpc"]
64+
65+
# Health check to ensure btcd is running
66+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
67+
CMD pgrep btcd || exit 1

docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: '2'
21
services:
32
# btc is an image of bitcoin node which used as base image for btcd and
43
# btccli. The environment variables default values determined on stage of
@@ -8,6 +7,7 @@ services:
87
container_name: btcd
98
build:
109
context: btcd/
10+
dockerfile: Dockerfile
1111
volumes:
1212
- shared:/rpc
1313
- bitcoin:/data

docker/lnd/start-lnd.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ HOSTNAME=$(hostname)
6060
# Also, setting --rpclisten to $HOSTNAME will cause it to listen on an IP
6161
# address that is reachable on the internal network. If you do this outside of
6262
# docker, this might be a security concern!
63+
# [:18556] is the default btcd RPC port in SIMNET network.
6364

6465
if [ "$BACKEND" == "bitcoind" ]; then
6566
exec lnd \
@@ -79,14 +80,12 @@ if [ "$BACKEND" == "bitcoind" ]; then
7980
elif [ "$BACKEND" == "btcd" ]; then
8081
exec lnd \
8182
--noseedbackup \
82-
"--$CHAIN.active" \
8383
"--$CHAIN.$NETWORK" \
8484
"--$CHAIN.node"="$BACKEND" \
8585
"--$BACKEND.rpccert"="$RPCCRTPATH" \
8686
"--$BACKEND.rpchost"="$RPCHOST" \
8787
"--$BACKEND.rpcuser"="$RPCUSER" \
8888
"--$BACKEND.rpcpass"="$RPCPASS" \
89-
"--rpclisten=$HOSTNAME:10009" \
9089
"--rpclisten=localhost:10009" \
9190
--debuglevel="$DEBUG" \
9291
"$@"

0 commit comments

Comments
 (0)