Skip to content

Commit 12f5b56

Browse files
committed
Update README.md for Bitcoin Core Docker Image
- Updated base image from `debian:bullseye-slim` to `debian:bookworm-slim`. - Added `BITCOIN_VERSION` build argument to specify the version of Bitcoin Core (default: `v29.0`). - Modified dependencies to include `cmake` and `libsqlite3-dev`. - Improved build process steps by specifying version checkout and using CMake. - Detailed improvements in final image dependencies, including `libssl3` and `libevent` libraries. - Enhanced security section by introducing a non-root `bitcoin` user and specifying ownership of the `/bitcoin` directory. - Updated Docker commands in the build and run sections to reflect the new default version of Bitcoin Core (`v29.0`). - Added security considerations regarding the non-root user setup. Signed-off-by: Artem Barger <artem@bargr.net>
1 parent 0c80d8a commit 12f5b56

File tree

1 file changed

+40
-16
lines changed

1 file changed

+40
-16
lines changed

README.md

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,59 @@ source and another for creating the final runtime image with only the necessary
99

1010
### Stage 1: Build Bitcoin Core
1111

12-
- **Base Image**: `debian:bullseye-slim`
12+
- **Base Image**: `debian:bookworm-slim`
13+
- **Build Arguments**:
14+
- `BITCOIN_VERSION`: Version of Bitcoin Core to build (default: `v29.0`)
1315
- **Dependencies Installed**:
14-
- `automake`, `autotools-dev`, `build-essential`, `git`, `libtool`, `pkg-config`, `python3-minimal`
16+
- `automake`, `cmake`, `autotools-dev`, `build-essential`, `git`, `libtool`, `pkg-config`, `python3-minimal`
1517
- Boost libraries (`libboost-system-dev`, `libboost-filesystem-dev`, `libboost-chrono-dev`, `libboost-program-options-dev`, `libboost-test-dev`,
1618
`libboost-thread-dev`)
1719
- OpenSSL and libevent development libraries
18-
- `libdb++-dev`, `bsdmainutils`
20+
- `libdb++-dev`, `bsdmainutils`, `libsqlite3-dev`
1921
- **Build Process**:
20-
- Clones the Bitcoin Core repository (`v25.1`).
21-
- Configures, builds, and strips the `bitcoin-cli` binary.
22+
- Clones the Bitcoin Core repository.
23+
- Checks out the specified version (default: `v29.0`).
24+
- Uses CMake to configure and build the binaries.
2225

2326
### Stage 2: Final Image
2427

25-
- **Base Image**: `debian:bullseye-slim`
28+
- **Base Image**: `debian:bookworm-slim`
2629
- **Dependencies Installed**:
27-
- Boost runtime libraries
28-
- OpenSSL and libevent runtime libraries
30+
- Boost runtime libraries (version 1.74.0)
31+
- `libssl3` (updated from libssl1.1)
32+
- `libevent-2.1-7`, `libevent-extra-2.1-7`, `libevent-pthreads-2.1-7`
2933
- `iproute2`, `iptables`
34+
- `libsqlite3-0`
3035
- **Binary Copies**:
31-
- `bitcoind` and `bitcoin-cli` from the builder stage.
36+
- `bitcoind` and `bitcoin-cli` from the builder stage, installed to `/usr/local/bin/`.
37+
- **Security**:
38+
- Creates a non-root `bitcoin` user and group to run the container.
39+
- Sets proper ownership of the `/bitcoin` directory.
3240
- **Volume**:
3341
- `/bitcoin` for data storage.
3442
- **Ports Exposed**:
3543
- `8332` (RPC)
3644
- `8333` (P2P)
3745
- **Entry Point**:
38-
- Runs `bitcoind` with default configuration options.
46+
- Runs `bitcoind` as the `bitcoin` user with default configuration options.
3947

4048
## How to Build the Image
4149

42-
To build the Docker image, navigate to the directory containing the `Dockerfile` and run the following command:
50+
### Default Build
51+
52+
To build the Docker image with the default Bitcoin Core version (v29.0), navigate to the directory containing the `Dockerfile` and run:
4353

4454
```sh
45-
docker build -t bitcoin-core:v25.1 .
55+
docker build -t bitcoin-core:v29.0 .
4656
```
4757

48-
This will create a Docker image tagged as `bitcoin-core:v25.1`.
58+
### Custom Version Build
59+
60+
To build a specific version of Bitcoin Core, use the `--build-arg` flag:
61+
62+
```sh
63+
docker build --build-arg BITCOIN_VERSION=v28.0 -t bitcoin-core:v28.0 .
64+
```
4965

5066
## How to Run the Container
5167

@@ -54,7 +70,7 @@ This will create a Docker image tagged as `bitcoin-core:v25.1`.
5470
To run a Bitcoin Core node, use the following command:
5571

5672
```sh
57-
docker run -d --name bitcoin-node -v bitcoin-data:/bitcoin -p 8332:8332 -p 8333:8333 bitcoin-core:v25.1
73+
docker run -d --name bitcoin-node -v bitcoin-data:/bitcoin -p 8332:8332 -p 8333:8333 bitcoin-core:v29.0
5874
```
5975

6076
- `-d`: Runs the container in detached mode.
@@ -72,7 +88,7 @@ You can provide a custom configuration file (`bitcoin.conf`) by mounting it into
7288
Example:
7389

7490
```sh
75-
docker run -d --name bitcoin-node -v bitcoin-data:/bitcoin -v /path/to/bitcoin.conf:/bitcoin/bitcoin.conf -p 8332:8332 -p 8333:8333 bitcoin-core:v25.1
91+
docker run -d --name bitcoin-node -v bitcoin-data:/bitcoin -v /path/to/bitcoin.conf:/bitcoin/bitcoin.conf -p 8332:8332 -p 8333:8333 bitcoin-core:v29.0
7692
```
7793

7894
### Using RPC
@@ -100,7 +116,15 @@ daemon=0
100116

101117
**Note**: Adjust the `rpcuser` and `rpcpassword` to secure your node.
102118

119+
## Security Considerations
120+
121+
This container runs as a non-root user (`bitcoin`), which provides an additional layer of security. The `bitcoin` user has:
122+
123+
- Limited permissions within the container
124+
- Ownership only of the `/bitcoin` directory
125+
- No login shell (`/sbin/nologin`)
126+
103127
## Conclusion
104128

105-
This Docker setup provides a convenient way to run a Bitcoin Core node in an isolated environment, making it easy to manage and scale. For more advanced
129+
This Docker setup provides a convenient and secure way to run a Bitcoin Core node in an isolated environment, making it easy to manage and scale. For more advanced
106130
configurations, refer to the [Bitcoin Core documentation](https://bitcoin.org/en/full-node).

0 commit comments

Comments
 (0)