This directory contains an example docker-compose.yml file which will allow you to run a full Bitcoin node. The compose file will automatically handle creating a data volume for you, so that blockchain data is persisted between Bitcoin upgrades. It also makes it easy to run bitcoin-cli
against your running Bitcoin node.
Before you can get started, you need to install Docker Compose. Follow the Docker Compose installation instructions relevant to your platform.
First, you should create a directory to keep your compose file in. Copy the example docker-compose.yml
file from this repository into your local directory.
$ mkdir bitcoin
$ cd bitcoin
$ wget https://raw.githubusercontent.com/NicolasDorier/docker-bitcoin/master/example/docker-compose.yml
To launch your node, simply type docker-compose up
:
$ docker-compose up -d # start bitcoind in the background
$ docker-compose ps # show running processes
$ docker-compose down # stop bitcoind (blockchain data will remain on disk)
To run commands against your running Bitcoin node, a bitcoin-cli
shorthand is provided. Simply use the docker-compose run
command:
$ docker-compose run --rm bitcoin-cli getinfo
Note that passing --rm
to docker-compose run
is not strictly necessary. However, it will prevent exited containers building up on your system after each command, which can waste disk space. If you forget to pass --rm
, the unused containers will be cleaned up next time you run docker-compose down
.
To configure your Bitcoin node, update the command: bitcoind
line in docker-compose.yml
. For example, to run a node on the Bitcoin testnet, you would change the line to:
command: bitcoind -testnet
The docker-compose.yml
file can be edited to suit your needs. If you wish to run a specific version or fork of bitcoin, simply replace NicolasDorier/bitcoin
with the desired image.