This Docker Compose template is used to run a Bitcoin node on Apple silicon Mac running macOS storing blockchain dataset on external APFS (Encrypted) volume.
One can either use Bitcoin Core or Bitcoin Knots and route traffic over Mullvad or Tor for additional privacy (Docker containers do not have direct Internet access, are isolated from macOS host and run as read-only).
An Electrs server is the only exposed service to which Electrum can connect on macOS via 127.0.0.1:50001.
If you wish to support this project, please star repo and consider a donation.
- Apple silicon Mac running macOS
- External APFS (Encrypted) volume (faster is better, aluminum NVMe enclosure recommended)
If you don’t have a spare enclosure and 2TB NVMe disk, here are two great options:
Budget option: sharge Disk Plus + 2TB WD_BLACK SN7100 M.2 2280 NVMe
Performance option: OWC Express 1M2 + 2TB SAMSUNG 990 PRO M.2 2280 NVMe
Both of these options can usually be purchased on Amazon (preferrably shipped and sold by Amazon for warranty).
When using a Mac with passive cooling, running utilities/monitor.sh is recommended. If thermal pressure isn’t nominal (green), using a stand and a fan is recommended during initial block download.
Heads-up: running
gitwill trigger “Command Line Tools” install unless already installed.
$ git clone https://github.com/sunknudsen/bitcoin-node-docker.git
$ cd bitcoin-node-dockerStep 2: install Homebrew
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
$ echo 'export PATH=$PATH:/opt/homebrew/bin' >> ~/.zshrc && source ~/.zshrc$ brew analytics offHeads-up: wakeful is used to prevent automatic sleep, gracefully stop Docker Compose services and eject external volume before computer sleeps.
$ brew install colima docker docker-compose sunknudsen/tap/wakefulStep 5: configure Docker
$ mkdir -p $HOME/.docker
$ cp config.json.sample $HOME/.docker/config.jsonStep 6: configure Colima
Heads-up: replace
Dockerwith external volume name and adjustcpuandmemoryif hardware can handle heavier workloads (defaults are optimized for Apple silicon MacBook Air computers with 8GB of memory and passive cooling).
$ export COLIMA_HOME=/Volumes/Docker
$ mkdir -p ${COLIMA_HOME}/bitcoin-node
$ cp colima.yaml.sample ${COLIMA_HOME}/bitcoin-node/colima.yaml
$ colima --profile bitcoin-node start \
--cpu 2 \
--disk 2048 \
--memory 4Heads-up: use
BITCOIND_DB_CACHEto set database cache memory allocation (defaults to2048).
Heads-up: use
BITCOIND_MAX_UPLOAD_TARGETto set daily upload target (defaults to unlimited, use500Mfor a 500MB per day upload target).
Heads-up: use
BITCOIND_PERSIST_MEMPOOLto set mempool persistence (defaults to non-persistent, use1to enable mempool persistence if node runs 24/71).
$ cp .env.sample .envWhen Bitcoin node does not run 24/7 or mempool persistence is disabled and node restarts, mempool is stale and, as a result, fee estimates are not consistent with network averages.
Before broadcasting transactions, it is recommended to allow node to sync to tip, wait a few hours for mempool to calibrate and confirm fee estimates using public mempool explorer such as https://mempool.space/.
Using Mullvad profile is recommended during initial block download to considerably speed things up (initial block download is expected to take about 48-72 hours using defaults on fast Internet connection and using wired Ethernet connection is recommended).
Using Tor outbound-only profile is recommended when running node on the go over cellular networks (warning: block download can still use considerable bandwidth so syncing node beforehand is recommended).
Using Tor profile is recommended after initial block download has completed.
Use Ctrl+C to stop node and eject volume.
Heads-up: replace
Dockerwith external volume name (if applicable).
Heads-up: requires Mullvad app and subscription and using WireGuard server.
$ mullvad connect
$ wakeful --grace-period 600 utilities/run.sh \
--profile bitcoin-core-over-mullvad \
--volume /Volumes/DockerHeads-up: replace
Dockerwith external volume name (if applicable).
$ wakeful --grace-period 600 utilities/run.sh \
--profile bitcoin-core-over-tor \
--volume /Volumes/DockerHeads-up: replace
Dockerwith external volume name (if applicable).
$ wakeful --grace-period 600 utilities/run.sh \
--profile bitcoin-core-over-tor-outbound-only \
--volume /Volumes/DockerHeads-up: replace
Dockerwith external volume name (if applicable).
Heads-up: requires Mullvad app and subscription and using WireGuard server.
$ mullvad connect
$ wakeful --grace-period 600 utilities/run.sh \
--profile bitcoin-knots-over-mullvad \
--volume /Volumes/DockerHeads-up: replace
Dockerwith external volume name (if applicable).
$ wakeful --grace-period 600 utilities/run.sh \
--profile bitcoin-knots-over-tor \
--volume /Volumes/DockerHeads-up: replace
Dockerwith external volume name (if applicable).
$ wakeful --grace-period 600 utilities/run.sh \
--profile bitcoin-knots-over-tor-outbound-only \
--volume /Volumes/DockerHeads-up: requires Electrum app.
Heads-up: run script used to start Electrum without data persistence using RAM disk.
$ electrum/run.sh$ brew upgrade colima docker docker-compose sunknudsen/tap/wakefulHeads-up: replace
v2.0.4with desired release tag.
$ git pull
$ git checkout v2.0.4Heads-up: use
utilities/update-dotenv.shto update .env to latest versions which may be contentious (use--dry-runto display latest versions without updating .env).
$ utilities/update-dotenv.shHeads-up: replace
bitcoin-core-over-torwith desired profile andDockerwith external volume name (if applicable).
Heads-up: running Bitcoin node will automatically trigger upgrade.
$ wakeful --grace-period 600 utilities/run.sh \
--profile bitcoin-core-over-tor \
--volume /Volumes/Docker$ docker image pruneHeads-up: replace
$HOME/bitcoin-node-dockerwith path to bitcoin-node-docker folder,bitcoin-core-over-torwith desired profile andDockerwith external volume name (if applicable).
Once aliases have been created, one can run bitcoin-node to start Bitcoin node and electrum to start Electrum without data persistence.
Use Ctrl+C to stop Bitcoin node and eject volume.
$ cat << 'EOF' >> $HOME/.zshrc
# Set bitcoin-node-docker aliases
alias bitcoin-node="wakeful --grace-period 600 $HOME/bitcoin-node-docker/utilities/run.sh --profile bitcoin-core-over-tor --volume /Volumes/Docker"
alias electrum="$HOME/bitcoin-node-docker/electrum/run.sh"
EOF
$ source $HOME/.zshrc