This guide provides step-by-step instructions for setting up a Bitcoin full node using Docker, with optional snapshot integration to accelerate the initial blockchain synchronization.
BTC/
├── compose.yml
└── btc-data/
└── bitcoin.conf
# compose.yml
services:
bitcoin-node:
image: ruimarinho/bitcoin-core:latest
container_name: bitcoin-node
ports:
- "8333:8333" # P2P port
- "8332:8332" # RPC port
volumes:
- ./btc-data:/home/bitcoin/.bitcoin# bitcoin.conf
server=1
listen=1
rpcuser=admin
rpcpassword=yourStrongPassword
rpcallowip=0.0.0.0/0
rpcbind=0.0.0.0
# Optional settings:
# Uncomment to enable prune mode
#prune=550
#txindex=0
# Performance tuning
dbcache=4096 # Use 4 GB for caching (adjust based on RAM)Start the Bitcoin node:
docker compose up -dStop the node:
docker compose downRestart the node:
docker compose down
docker compose up -dView real-time logs:
docker compose logs -fCheck Blockchain Sync Status:
docker exec -it bitcoin-node bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfoCheck Connected Peers:
docker exec -it bitcoin-node bitcoin-cli -datadir=/home/bitcoin/.bitcoin getconnectioncountWatch Live Sync Progress (Optional):
watch -n 5 "docker exec -it bitcoin-node bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo"This will refresh the blockchain sync info every
5 seconds. PressCtrl+Cto stop watching.
To speed up the initial sync, you can use a trusted Bitcoin snapshot. There are two options:
-
Replace the
blocks/andchainstate/folders insidebtc-data/with snapshot data. After that: -
Temporarily override the command in
compose.ymlby adding:
command: ["bitcoind", "-reindex-chainstate"] # 👈 Add temporarily# compose.yml
services:
bitcoin-node:
image: ruimarinho/bitcoin-core:latest
container_name: bitcoin-node
command: ["bitcoind", "-reindex-chainstate"] # 👈 Add temporarily
ports:
- "8333:8333"
- "8332:8332"
volumes:
- ./btc-data:/home/bitcoin/.bitcoin- Run and monitor:
docker compose up -d
docker compose logs -f- After reindex completes, remove the
commandline and restart:
docker compose down
docker compose up -dReplace the entire btc-data/ folder with the one from the snapshot source.
Ensure
prune=550(or your value) is set inbitcoin.conf.
✅ Do NOT use -reindex or -reindex-chainstate. That will delete pruned data and force full sync from 0.
Start the node normally:
docker compose up -dstart:
docker compose up -d
down:
docker compose down
restart:
docker compose down
docker compose up -d
logs:
docker compose logs -f
info:
docker exec -it bitcoin-node bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo
peers:
docker exec -it bitcoin-node bitcoin-cli -datadir=/home/bitcoin/.bitcoin getconnectioncount
After creating the Makefile, you can use:
make start
make logs
make info