diff --git a/contrib/docker/bitcoin-abc/Dockerfile b/contrib/docker/bitcoin-abc/Dockerfile new file mode 100644 --- /dev/null +++ b/contrib/docker/bitcoin-abc/Dockerfile @@ -0,0 +1,27 @@ +FROM debian:buster-slim + +ARG RELEASE_ARCHIVE +COPY "${RELEASE_ARCHIVE}" /tmp + +RUN tar xzf "/tmp/${RELEASE_ARCHIVE}" -C /usr/local --strip-components=1 --exclude="*-qt" +RUN rm -f "/tmp/${RELEASE_ARCHIVE}" + +RUN groupadd -r bitcoin +RUN useradd -rmg bitcoin bitcoin + +ENV BITCOIN_DATA /data + +# Set permissions on the data directory +RUN mkdir "${BITCOIN_DATA}" +RUN chown -R bitcoin:bitcoin "${BITCOIN_DATA}" +RUN ln -sfn "$BITCOIN_DATA" /home/bitcoin/.bitcoin +RUN chown -h bitcoin:bitcoin /home/bitcoin/.bitcoin + +# We need to declare the volume AFTER the directory is created and permissions +# are set, otherwise the changes won't be persistent +VOLUME "${BITCOIN_DATA}" + +EXPOSE 8332 8333 18332 18333 + +USER bitcoin +CMD ["bitcoind"] diff --git a/contrib/docker/bitcoin-abc/README.md b/contrib/docker/bitcoin-abc/README.md new file mode 100644 --- /dev/null +++ b/contrib/docker/bitcoin-abc/README.md @@ -0,0 +1,58 @@ +# Running the Bitcoin ABC node software inside a Docker container + +## Building your Docker image + +From this directory: +1. [Download](https://www.bitcoinabc.org/releases/) the release archive for your target system. + This example assumes that you downloaded the file `bitcoin-abc-0.22.3-x86_64-linux-gnu.tar.gz` +2. Build the image: + +```shell +docker build -t bitcoin-abc:0.22.3 --build-arg RELEASE_ARCHIVE=bitcoin-abc-0.22.3-x86_64-linux-gnu.tar.gz . +``` + +## Running the node software + +By default the container will execute `bitcoind`: + +```shell +docker run bitcoin-abc:0.22.3 +``` + +To pass options to `bitcoind`, pass them as arguments to the container: + +```shell +docker run bitcoin-abc:0.22.3 bitcoind -version +``` + +You can also run another tool by specifying it as an argument to the container: + +```shell +docker run bitcoin-abc:0.22.3 bitcoin-cli -version +``` + +## Persistent data directory + +The container uses `/data` volume as the default data directory. +To make this directory persistent across container runs, you can bind the +volume to your local filesystem: + +```shell +mkdir ~/bitcoin-abc-data +docker run -v ~/bitcoin-abc-data:/data bitcoin-abc:0.22.3 +``` + +**Note: Make sure the container has write access to you local folder.** + +## Communication between bitcoin-cli and bitcoind + +In order to make `bitcoin-cli` and `bitcoind` communicate together, they need to +use the same network. By using the same data directory, they also share the +authentication cookie: + +```shell +# Run the bitcoind container in the background +docker run --name bitcoind -v ~/bitcoin-abc-data:/data --rm -d bitcoin-abc:0.22.3 +docker run --network container:bitcoind -v ~/bitcoin-abc-data:/data --rm bitcoin-abc:0.22.3 bitcoin-cli getnetworkinfo +docker stop bitcoind +```